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: Accepted)

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
ll modpow(ll b, ll e ,ll mod) {
	ll ans = 1;
	for (; e; b = b * b % mod, e /= 2)
		if (e & 1) ans = ans * b % mod;
	return ans;
}

/**
 * Description: Class to handle points in the plane.
 * 	T can be e.g. double or long long. (Avoid int.)
 * Status: Works fine, used a lot
 */

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P normalize(){
		if(x == 0){
			return P(0,1);
		}
		if(y == 0){
			return P(1,0);
		}
		ll gc = __gcd(x,y);
		P k = P(x/gc,y/gc);
		if(k.y < 0) k.x = -k.x , k.y = -k.y;
		return k;
	}
	P perp() const {
		if(x == 0){
			return P(1,0);
		}
		if(y == 0){
			return P(0,1);
		}
		ll gc = __gcd(x,y);
		P k = P(-y/gc,x/gc);
		if(k.y < 0) k.x = -k.x , k.y = -k.y;
		return k;
	}
	
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};

typedef Point<ll> P;
const ll mod = 1000000007;



int32_t main(){
	ll ans = 1;
	int n;
	cin >> n;
	map<P, ll> cnt;
	ll f = 0 ;
	vector<P> v(n);
	for(int i = 0 ; i < n; i ++){
		ll x,y;
		cin >> x >> y;
		if(x == 0 && y== 0){
			f ++ ;
		}		
		else{
			cnt[P(x,y).normalize()] ++ ;
		}
	}
	set<P> jf;
	for(auto w : cnt){
		if(!jf.count(w.first)){
			ans  = (ans *(modpow(2, w.second ,mod) + modpow(2 , cnt[w.first.perp()] , mod) - 1 + mod)%mod) % mod;
			jf.insert(w.first);
			jf.insert(w.first.perp());
		}
	}
	ans = (ans + f - 1)%mod;
	if(ans < 0) ans += mod;
	cout << ans << endl;
}