#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long mod = 1e9 + 7;
const int inf = 1 << 30;
long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
long long rui(long long a, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = ans * a % mod;
    a = a * a % mod;
    n /= 2;
  }
  return ans;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i] >> b[i];
  map<pair<int, int>, long long> mp1;
  map<pair<int, int>, long long> mp2;
  long long N = 0;
  long long ans = 1;
  for (int i = 0; i < (int)(n); i++) {
    long long x, y;
    if (b[i] != 0) {
      x = a[i] / gcd(a[i], b[i]);
      y = b[i] / gcd(a[i], b[i]);
    } else if (a[i] != 0) {
      x = 1, y = 0;
    } else {
      N++;
      n--;
      continue;
    }
    mp1[pair<int, int>(x, y)]++;
    if (x != 0)
      mp2[pair<int, int>(-y / gcd(y, x), x / gcd(y, x))]++;
    else
      mp2[pair<int, int>(1, 0)]++;
  }
  for (auto c : mp1) {
    if (c.second == 0 || mp2[c.first] == 0) continue;
    long long x = c.first.first;
    long long y = c.first.second;
    ans = ans * (rui(2, c.second) + rui(2, mp2[c.first]) - 1) % mod;
    n -= c.second + mp2[c.first];
    c.second = 0;
    mp1[pair<int, int>(-y / gcd(y, x), x / gcd(y, x))] = 0;
  }
  ans = (ans * rui(2, n) - 1) % mod;
  ans = (ans + N) % mod;
  if (ans < 0) ans += mod;
  cout << ans << endl;
}
