#include <bits/stdc++.h>
using namespace std;
long long int gdc(long long int a, long long int b) {
  if (a == 0) return b;
  if (a == b) return a;
  if (a > b) return gdc(a % b, b);
  return gdc(b % a, a);
}
int modadd(int a, int b) {
  long long int al = (long long int)a;
  long long int bl = (long long int)b;
  if (al + bl >= 1000000007) return (int)(al + bl - 1000000007);
  return (int)(al + bl);
}
int modmul(int a, int b) {
  long long int al = (long long int)a;
  long long int bl = (long long int)b;
  return (int)((al * bl) % 1000000007);
}
long long int *_ga;
long long int *_gb;
bool comp(int i1, int i2) {
  if (_ga[i1] < _ga[i2]) return true;
  if (_ga[i1] > _ga[i2]) return false;
  return (_gb[i1] < _gb[i2]);
}
bool isEqual(int i1, int i2) {
  return (_ga[i1] == _ga[i2] && _gb[i1] == _gb[i2]);
}
int main(void) {
  int n;
  cin >> n;
  long long int *a = (long long int *)malloc(sizeof(long long int) * n);
  long long int *b = (long long int *)malloc(sizeof(long long int) * n);
  _ga = a;
  _gb = b;
  vector<int> l;
  vector<int> r;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin >> b[i];
    if (b[i] < 0) {
      b[i] = -b[i];
      a[i] = -a[i];
    }
    if (a[i] < 0) {
      a[i] = -a[i];
      l.push_back(i);
    } else {
      long long int tmp = a[i];
      a[i] = b[i];
      b[i] = tmp;
      r.push_back(i);
    }
    long long int g = gdc(a[i], b[i]);
    a[i] /= g;
    b[i] /= g;
  }
  sort(l.begin(), l.end(), comp);
  sort(r.begin(), r.end(), comp);
  auto litr = l.begin();
  auto ritr = r.begin();
  int ans = 1;
  while (litr != l.end() || ritr != r.end()) {
    if (litr == l.end()) {
      while (ritr != r.end()) {
        ans = modmul(ans, 2);
        *ritr++;
      }
    }
    if (ritr == r.end()) {
      while (litr != l.end()) {
        ans = modmul(ans, 2);
        *litr++;
      }
    } else {
      if (isEqual(*litr, *ritr)) {
        int lcount = 1;
        int lindex = *litr;
        while (litr != l.end() && isEqual(*litr, lindex)) {
          lcount = modmul(lcount, 2);
          litr++;
        }
        int rcount = 1;
        int rindex = *ritr;
        while (ritr != r.end() && isEqual(*ritr, rindex)) {
          rcount = modmul(rcount, 2);
          ritr++;
        }
        int tmpf = modadd(modadd(rcount, lcount), 1000000007 - 1);
        ans = modmul(ans, tmpf);
      } else if (comp(*litr, *ritr)) {
        ans = modmul(ans, 2);
        litr++;
      } else {
        ans = modmul(ans, 2);
        ritr++;
      }
    }
  }
  cout << modadd(ans, 1000000007 - 1);
}
