#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long A[200000];
long long B[200000];
pair<long long, long long> frac_AB[200000];
long long two_power[200001];
long long gcd(long long m, long long n) {
  if (n > m) {
    return gcd(n, m);
  } else if (n == 0) {
    return m;
  }
  return gcd(n, m % n);
}
pair<long long, long long> get_inv_neg(pair<long long, long long> a) {
  if (a.first < 0) {
    return make_pair(a.second, -a.first);
  }
  return make_pair(a.second, a.first);
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  two_power[0] = 1;
  for (int i = 1; i <= N; i++) {
    two_power[i] = (two_power[i - 1] * 2) % MOD;
  }
  long long A_zero_count = 0;
  long long B_zero_count = 0;
  long long both_zero_count = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] != 0 && B[i] != 0) {
      long long tmp = gcd(abs(A[i]), abs(B[i]));
      if ((A[i] > 0 && B[i] > 0) || (A[i] < 0 && B[i] < 0)) {
        frac_AB[i] = make_pair(abs(A[i]) / tmp, abs(B[i]) / tmp);
      } else {
        frac_AB[i] = make_pair(-abs(A[i]) / tmp, abs(B[i] / tmp));
      }
    } else if (A[i] == 0 && B[i] != 0) {
      A_zero_count++;
      frac_AB[i] = make_pair(0, B[i]);
    } else if (A[i] != 0 && B[i] == 0) {
      B_zero_count++;
      frac_AB[i] = make_pair(A[i], 0);
    } else {
      both_zero_count++;
      frac_AB[i] = make_pair(0, 0);
    }
  }
  map<pair<long long, long long>, int> frac_counts;
  long long ans = 1;
  for (int i = 0; i < N; i++) {
    if (frac_counts.find(frac_AB[i]) == frac_counts.end()) {
      frac_counts[frac_AB[i]] = 1;
    } else {
      frac_counts[frac_AB[i]]++;
    }
  }
  set<pair<long long, long long> > done;
  for (auto it = frac_counts.begin(); it != frac_counts.end(); it++) {
    if (it->first.first == 0 || it->first.second == 0 ||
        done.find(it->first) != done.end()) {
      continue;
    }
    long long cur = (two_power[it->second] - 1 + MOD) % MOD;
    done.insert(it->first);
    pair<long long, long long> inv_neg = get_inv_neg(it->first);
    if (frac_counts.find(inv_neg) != frac_counts.end()) {
      cur = (cur + (two_power[frac_counts[inv_neg]] - 1 + MOD) % MOD) % MOD;
      done.insert(inv_neg);
    }
    ans = (ans * (cur + 1)) % MOD;
  }
  if (A_zero_count != 0 || B_zero_count != 0) {
    long long A_tmp = (two_power[A_zero_count] - 1 + MOD) % MOD;
    long long B_tmp = (two_power[B_zero_count] - 1 + MOD) % MOD;
    ans = (ans * ((A_tmp + B_tmp + 1 + MOD) % MOD)) % MOD;
  }
  ans = (ans - 1 + MOD) % MOD;
  ans = (ans + both_zero_count) % MOD;
  cout << ans << endl;
  return 0;
}
