#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  vector<vector<long long>> b0, ab0;
  vector<pair<long long, long long>> p, p2;
  long long def = 1e+9;
  def += 7;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    long long d = gcd(a[i], b[i]);
    a[i] /= d;
    b[i] /= d;
    if (a[i] < 0) {
      a[i] *= -1;
      b[i] *= -1;
    }
    p.push_back(make_pair(a[i], b[i]));
  }
  sort(p.begin(), p.end());
  int ps = p.size();
  p2.push_back(p[0]);
  map<long long, map<long long, long long>> m, m2;
  m[p[0].first][p[0].second]++;
  for (int i = 1; i < ps; i++) {
    if (p[i].first != p[i - 1].first || p[i].second != p[i - 1].second) {
      p2.push_back(p[i]);
    }
    m[p[i].first][p[i].second]++;
  }
  vector<long long> power2(n + 1);
  power2[0] = 1;
  for (int i = 1; i <= n; i++) {
    power2[i] = power2[i - 1] * 2;
    power2[i] %= def;
  }
  vector<long long> ans(p2.size());
  long long sum = m[p2[0].first][p2[0].second];
  ans[0] = power2[sum] - 1;
  long long ans2 = 1;
  for (int i = 0; i < p2.size(); i++) {
    long long tempm = m[p2[i].first][p2[i].second];
    long long co;
    if (p2[i].second < 0) {
      if (m2[-p2[i].second][p2[i].first]) {
        m2[-p2[i].second][p2[i].first]--;
      }
      m2[-p2[i].second][p2[i].first] += power2[tempm];
      co = m2[-p2[i].second][p2[i].first];
    } else {
      if (m2[p2[i].first][p2[i].second]) {
        m2[p2[i].first][p2[i].second]--;
      }
      m2[p2[i].first][p2[i].second] += power2[tempm];
      co = m2[p2[i].first][p2[i].second];
    }
  }
  for (auto x : m2) {
    for (auto y : x.second) {
      if (y.first >= 0) {
        ans2 *= y.second;
        ans2 %= def;
      }
    }
  }
  cout << ans2 - 1 << endl;
  return 0;
}
