Problem:
Score: 500 points

Problem Statement

We have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, 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 i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.

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 1000000007.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

-10^{18} \leq A_i, B_i \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N
A_1 B_1
:
A_N B_N

Output

Print the count modulo 1000000007.

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 1-st

The 1-st and 2-nd

The 2-nd

The 2-nd and 3-rd

The 3-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

Solution in C++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX=200001;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int powMOD(int n,int r){
    if(r<=0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

signed main(){
    int N;cin>>N;
    double X[N],Y[N];
  	REP(i,N)X[i]=INF;
    map<double,int>umemo;
    map<double,int>smemo;
    map<double,bool>used;
  	int Ac=0,Bc=0;
    REP(i,N){
        double a,b;cin>>a>>b;
      	if((a==0)||(b==0)){
          	if(a==0&&b==0){
              	continue;
            }
          	if(a==0)Ac++;
          	if(b==0)Bc++;
        }
        X[i]=a/b;
        umemo[a/b]++;
        smemo[(-b/a)]++;
        used[a/b]=false;
    }
    int ans=1;
    REP(i,N){
      	if(X[i]==INF)continue;
        if(used[X[i]])continue;
        used[X[i]]=true;
        used[-1.0/X[i]]=true;
        int d=0;
        if(smemo[X[i]]==0){
            d=powMOD(2,umemo[X[i]]);
        }
        else{
          	d=-1;
            d=(d+powMOD(2,umemo[X[i]]))%MOD;
            d=(d+powMOD(2,smemo[X[i]]))%MOD;
        }
      	while(d<0)d+=MOD;
		ans=ans*d%MOD;
    }
  	int d=-1;
  	d=(d+powMOD(2,Ac)%MOD);
    d=(d+powMOD(2,Bc)%MOD);
    ans=ans*d%MOD;
  	ans--;
    while(ans<0)ans+=MOD;
    cout<<ans<<endl;
}