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)

#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//こんなクソコードを生み出してしまうなんて趣味は罪ね

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

const ull ma = (1ull << 52) - 1;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	ull AB[200001];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int ka = 0, kb = N - 1;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		if (a < 0) {
			a = -a;
			b = -b;
		}
		bool p = (b > 0);
		if (!p) {
			b = -b;
			swap(a, b);
		}

		ull tmp = 0;
		rep(i, 3) {
			if (b) {
				int k = __builtin_clzll(a) - __builtin_clzll(b);
				if (k > 0) a <<= k;
				else b <<= -k;
				if (a > b) {
					b <<= 1;
					k--;
				}
				double d = double(b) / a;
				ull tmp1 = *(ull*)& d;
				ull c = tmp1 & ma | (1ull << 52);
				lll sa = (lll(b) << 52) - lll(a) * c;
				while (sa >= 0) {
					sa -= a;
					c++;
				}
				while (sa < 0) {
					sa += a;
					c--;
				}
				tmp += ull(k + 63) << 53 | c;
				tmp *= 3;
				b = sa;
			}
		}

		if (p) AB[i] = tmp | 1ull;
		else AB[i] = tmp & ~1ull;
	}
	sort(AB, AB + N);

	ll kotae = 1;
	ull mae = AB[0] >> 1;
	int k1 = 0, k2 = 0;
	rep(i, N) {
		if (mae != AB[i] >> 1) {
			kotae = kotae * (modpow(2, k1) + modpow(2, k2) - 1) % mod;
			k1 = 0;
			k2 = 0;
			mae = AB[i] >> 1;
		}
		if (AB[i] & 1ull) k1++;
		else k2++;
	}
	kotae = kotae * (modpow(2, k1) + modpow(2, k2) - 1) % mod;

	kotae = kotae * (modpow(2, a0) + modpow(2, b0) - 1) % mod;

	co((kotae - 1 + ab00 + 2 * mod) % mod);

	Would you please return 0;
}