#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
const long mod = 1000000007;
long gcd(long a, long b){return b?gcd(b,a%b):a;}
long modpow(long x, long y, long m){
	long res = 1, tmp = x;
	while(y){
		if(y&1)res = res * tmp % m;
		tmp = tmp * tmp % m;
		y >>= 1;
	}
	return res;
}
long pom(long x, long y){return modpow(x, y, mod);}
typedef struct{
	long x, y;
}cor;
bool cor_lt(cor u, cor v){
	if(u.x < v.x)return true;
	if(u.x == v.x && u.y > v.y)return true;
	return false;
}
bool cor_eq(cor u, cor v){
	return u.x==v.x && u.y==v.y;
}
bool cor_gt(cor u, cor v){
	return !cor_lt(u, v) && !cor_eq(u, v);
}
int cmp(const void *a, const void *b){
	cor u = *(cor*)a, v = *(cor*)b;
	return cor_lt(u, v)?1:cor_eq(u, v)?0:-1;
}
int N, cnt_zero = 0;
long ans = 1;
cor A[1<<18];
int lower_bound(cor u){
	int l = -1, r = N;
	while(r - l > 1){
		int mid = (r + l) / 2;
		if(cor_gt(A[mid], u))l = mid;
		else r = mid;
	}
	return r;
}
int upper_bound(cor u){
	int l = -1, r = N;
	while(r - l > 1){
		int mid = (r + l) / 2;
		if(cor_lt(A[mid], u))r = mid;
		else l = mid;
	}
	return r;
}
int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		long s, t;
		scanf("%ld%ld", &s, &t);
		if(t < 0){
			s *= -1;
			t *= -1;
		}
		if(s == 0){
			if(t) t = 1;
			else {
				cnt_zero++;
				i--;
				N--;
			}
		}else if(t == 0){
			s = 1;
		}else {
			long x = gcd(labs(s), labs(t));
			s /= x;
			t /= x;
		}
		if(true){
			A[i].x = s;
			A[i].y = t;
		}
	}
	qsort(A, N, sizeof(cor), cmp);
	if(N){
		int cnt = 1, i = 1;
		cor tmp;
		for(; i<N && A[i].x > 0; i++){
			if(cor_eq(A[i], A[i-1]))cnt++;
			else{
				tmp.x = A[i-1].y;
				tmp.y = -A[i-1].x;
				if(tmp.y < 0){
					tmp.x *= -1;
					tmp.y *= -1;
				}
				ans = ans * (pom(2, cnt) + pom(2, upper_bound(tmp) - lower_bound(tmp)) - 1) % mod;
				cnt = 1;
			}
		}
		tmp.x = A[i-1].y;
		tmp.y = -A[i-1].x;
		if(tmp.y < 0){
			tmp.x *= -1;
			tmp.y *= -1;
		}
		ans = ans * (pom(2, cnt) + pom(2, upper_bound(tmp) - lower_bound(tmp)) - 1) % mod;
		cnt = 1;
		for(i += A[i-1].x > 0; i<N; i++){
			if(cor_eq(A[i], A[i-1]))cnt++;
			else{
				tmp.x = A[i-1].y;
				tmp.y = -A[i-1].x;
				if(tmp.y < 0){
					tmp.x *= -1;
					tmp.y *= -1;
				}
				if(upper_bound(tmp) == lower_bound(tmp)){
					ans = ans * pom(2, cnt) % mod;
				}
				cnt = 1;
			}
		}
		tmp.x = A[i-1].y;
		tmp.y = -A[i-1].x;
		if(tmp.y < 0){
			tmp.x *= -1;
			tmp.y *= -1;
		}
		if(upper_bound(tmp) == lower_bound(tmp))ans = ans * pom(2, cnt) % mod;
	}
	ans = (ans + cnt_zero - 1 + mod) % mod;
	printf("%ld\n", ans);
	return 0;
}