#include <bits/stdc++.h>
using namespace std;
int read() {
  char x = getchar();
  int u = 0, fg = 0;
  while (!isdigit(x)) {
    if (x == '-') fg = 1;
    x = getchar();
  }
  while (isdigit(x)) {
    u = (u << 3) + (u << 1) + (x ^ 48);
    x = getchar();
  }
  return fg ? -u : u;
}
const int maxx = 2e5 + 10;
const int mod = 1e9 + 7;
int n, cnt = 0;
long long a[maxx], b[maxx], ans[maxx];
double t[maxx];
map<double, long long> m;
long long qpow(long long y) {
  long long x = 2, tmp = 1;
  while (y > 1) {
    if (y & 1) tmp = tmp * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return tmp * x % mod;
}
int main() {
  scanf("%d", &n);
  for (register int i = (1); i <= (n); ++i) {
    scanf("%lld%lld", &a[i], &b[i]);
    t[i] = 1.0 * a[i] / (double)b[i];
    m[t[i]]++;
  }
  for (register int i = (1); i <= (n); ++i) {
    if (!m[t[i]]) continue;
    if (m[-1.0 / t[i]]) {
      ans[++cnt] = (qpow(m[t[i]]) + qpow(m[-1.0 / t[i]]) - 1) % mod;
      m[t[i]] = m[-1.0 / t[i]] = 0;
    } else {
      ans[++cnt] = qpow(m[t[i]]);
      m[t[i]] = 0;
    }
  }
  long long llz = ans[1];
  for (register int i = (2); i <= (cnt); ++i) llz = llz * ans[i] % mod;
  llz = (llz - 1ll + mod) % mod;
  printf("%lld\n", llz);
  return 0;
}
