#include <bits/stdc++.h>
using namespace std;
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  int n;
  cin >> n;
  map<pair<long long, long long>, long long> c, f;
  set<pair<long long, long long> > e;
  for (int i = 0; i < (int)(n); i++) {
    long long a, b;
    cin >> a >> b;
    long long GCD = gcd(abs(a), abs(b));
    a /= GCD;
    b /= GCD;
    if (a >= 0 && b >= 0) {
      c[make_pair(abs(a), abs(b))]++;
      f[make_pair(abs(a), abs(b))] = 1;
      f[make_pair(-abs(b), abs(a))] = 1;
      e.insert(make_pair(abs(a), abs(b)));
    } else {
      c[make_pair(-abs(a), abs(b))]++;
      f[make_pair(-abs(a), abs(b))] = 1;
      f[make_pair(abs(b), abs(a))] = 1;
      e.insert(make_pair(-abs(a), abs(b)));
    }
  }
  vector<long long> d(n + 1);
  d[0] = 1;
  for (int i = 0; i < (int)(n); i++) {
    d[i + 1] = d[i] * 2;
    d[i + 1] %= 1000000007;
  }
  long long ans = 1;
  for (auto x : e) {
    if (f[x] == 1 && f[make_pair(-x.second, x.first)] == 1 && x.first >= 0) {
      ans *= (d[c[x]] + d[c[make_pair(-x.second, x.first)]] - 1);
      f[x] = 0;
      f[make_pair(-x.second, x.first)] = 0;
    } else if (f[x] == 1 && f[make_pair(x.second, -x.first)] == 1 &&
               x.first < 0) {
      ans *= (d[c[x]] + d[c[make_pair(x.second, -x.first)]] - 1);
      f[x] = 0;
      f[make_pair(x.second, -x.first)] = 0;
    }
    ans %= 1000000007;
    while (ans < 0) ans += 1000000007;
  }
  ans--;
  while (ans < 0) ans += 1000000007;
  cout << ans << endl;
}
