#include <stdio.h>
#include <stdlib.h>

#define HASH 100003
#define Mod 1000000007

typedef struct List {
	struct List *next;
	long long a, b;
	int num;
} list;

long long gcd(long long a, long long b)
{
	if (a > b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	if (b % a == 0) return a;
	else return gcd(b % a, a);
}

int main()
{
	int h, i, N;
	long long A[200001], B[200001], G;
	list *p, *hash[HASH] = {}, d[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%lld %lld", &(A[i]), &(B[i]));
		if (A[i] == 0 && B[i] == 0);
		else if (A[i] == 0) B[i] = 1;
		else if (B[i] == 0) A[i] = 1;
		else {
			G = gcd(llabs(A[i]), llabs(B[i]));
			A[i] /= G;
			B[i] /= G;
			if (A[i] < 0) {
				A[i] *= -1;
				B[i] *= -1;
			}
		}
		h = (A[i] % HASH + B[i] % HASH * 397 + HASH) % HASH;
		for (p = hash[h]; p != NULL; p = p->next) if (p->a == A[i] && p->b == B[i]) break;
		if (p != NULL) p->num++;
		else {
			d[i].a = A[i];
			d[i].b = B[i];
			d[i].num = 1;
			d[i].next = hash[h];
			hash[h] = &(d[i]);
		}
	}
	
	long long ans = 1, pow[200001], tmp;
	list *q, *r;
	for (i = 1, pow[0] = 1; i <= N; i++) pow[i] = pow[i-1] * 2 % Mod;
	for (h = 0; h < HASH; h++) {
		for (p = hash[h]; p != NULL; p = p->next) {
			if (p->num > 0) {
				if (p->a == 0 && p->b == 0) {
					for (q = hash[1]; q != NULL; q = q->next) if (q->b == 0) break;
					for (r = hash[397]; r != NULL; r = r->next) if (r->a == 0) break;
					tmp = p->num + 1;
					if (q != NULL) {
						tmp += pow[q->num] - 1;
						q->num = 0;
					}
					if (r != NULL) {
						tmp += pow[r->num] - 1;
						r->num = 0;
					}
					ans = ans * tmp % Mod;
				} else {
					tmp = (p->b <= 0)? p->a: -(p->a);
					i = (llabs(p->b) % HASH + tmp % HASH * 397 + HASH) % HASH;
					for (q = hash[i]; q != NULL; q = q->next) if (q->a == llabs(p->b) && q->b == tmp) break;
					if (q == NULL) ans = ans * pow[p->num] % Mod;
					else {
						ans = ans * (pow[p->num] + pow[q->num] - 1) % Mod;
						q->num = 0;
					}
				}
			}
		}
	}
	printf("%lld\n", (ans + Mod - 1) % Mod);
	fflush(stdout);
	return 0;
}