#abc168e. [abc168_e]∙ (Bullet)
[abc168_e]∙ (Bullet)
Problem Statement
We have caught sardines. The deliciousness and fragrantness of the -th sardine is and , respectively.
We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.
The -th and -th sardines are on bad terms if and only if .
In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the count modulo .
Sample Input 1
3
1 2
-1 1
2 -1
Sample Output 1
5
There are five ways to choose the set of sardines, as follows:
- The -st
- The -st and -nd
- The -nd
- The -nd and -rd
- The -rd
Sample Input 2
10
3 2
3 2
-1 1
2 -1
-3 -9
-8 12
7 7
8 1
8 2
8 4
Sample Output 2
479