#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
map<pair<long long, long long>, long long> mp;
vector<pair<long long, long long> > G;
int n;
void add(long long &x, long long y) {
  y = (y + mod) % mod;
  x = (x + y) % mod;
}
void solve() {
  scanf("%d", &n);
  long long sum = 0, ans = 1;
  for (int i = 1; i <= (n); ++i) {
    long long fz, fm;
    scanf("%lld%lld", &fz, &fm);
    long long gc = gcd(fz, fm);
    if (gc == 0) {
      sum++;
      continue;
    }
    fz /= gc, fm /= gc;
    if (fm < 0) fm = -fm, fz = -fz;
    mp[{fz, fm}]++;
    G.push_back({fz, fm});
  }
  sort(G.begin(), G.end());
  G.erase(unique(G.begin(), G.end()), G.end());
  for (auto now : G) {
    if (mp[now] == 0) continue;
    long long fz = now.first, fm = now.second;
    long long d = powmod(2, mp[now]);
    fm = -fm;
    if (fz < 0) fz = -fz, fm = -fm;
    if (mp[{fm, fz}]) {
      add(d, powmod(2, mp[{fm, fz}]) - 1);
      mp[{fm, fz}] = 0;
    }
    mp[now] = 0;
    ans = ans * d % mod;
  }
  add(ans, sum - 1);
  printf("%lld\n", ans);
}
int main() { solve(); }
