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: Runtime Error)

#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))
#define N 200005

ll a[N], b[N];

ll GCD(ll a, ll b) {
	return a ? GCD(b % a, a) : b;
}

ll mod = 1000000007ll;

int main(void) {
	int n;
	scanf("%d", &n);
	map<pair<ll, ll>, int> m;

	REP(i, n) {
		scanf("%lld%lld", &a[i], &b[i]);
		ll gcd = GCD(abs(a[i]), abs(b[i]));
		a[i] /= gcd;
		b[i] /= gcd;
		if (b[i] < 0) {
			b[i] = -b[i];
			a[i] = -a[i];
		}

		m[mp(a[i], b[i])]++;
	}

	set<pair<ll, ll> > s;
	ll mn = 1ll;
	ll prev = 1ll;

	for (map<pair<ll, ll>, int>::iterator it = m.begin(); it != m.end(); it++) {
		pair<ll, ll> r((*it).X.Y * -1, (*it).X.X);
		if (r.Y < 0) {
			r.Y = -r.Y;
			r.X = -r.X;
		}

		if (s.find(r) != s.end()) {
			continue;
		}

		if (m.count(r) == 0) {
			mn = (mn * 2) % mod;
		}
		else {
			ll cnt = bit64((*it).Y) + bit64(m[r]) - 2;
			prev = ((prev * cnt) % mod + prev) % mod;
			s.insert((*it).X);
		}
	}

	ll res = (prev * mn) % mod;
	res--;
	if (res < 0) {
		res += mod;
	}

	printf("%lld\n", res);


	return 0;
}