#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> fac;

void init(int n) {
  fac  = vector<int>(n);
  fac[0] = fac[1] = 1;
  for (int i = 2; i < n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
  }
}

int f(int n){
  return fac[n]-1;
}
 
signed main() {
  int N; 
  cin >> N;

  map<pair<int, int>, pair<int, int>> m;

  int zero = 0;
  REP(i, N){
    int x, y;
    cin >> x >> y;
    if(x == 0 && y == 0){
      zero++;
      continue;
    }

    int g = gcd(x, y);
    x /= g; y /= g;
    if(y < 0){
      x = -x;
      y = -y;
    }
    if(y == 0 && x < 0) x = -x;

    bool rot = false;
    if(x <= 0) rot = true;
    if(rot){
      int tmp = x;
      x = y; y = -tmp;
    }
    if(rot) m[{x, y}].first++;
    else m[{x, y}].second++;
  }

  auto f = [&](int n){
    return (int)pow(2, n)-1;
  };

  int ans = 1;
  for(auto p : m){
    int v = p.second.first;
    int u = p.second.second;
    int now = (f(v)+f(u)+1)%MOD;
    (ans *= now) %= MOD;
  }

  cout << ans+zero-1 << "\n";

  return 0;
}