#include <bits/stdc++.h>
using namespace std;
const int MAXN = 205;
const long long int inf = 1e18;
long long int mod = 998244353;
long long int gc(long long int a, long long int b) {
  if (b == 0) return a;
  return gc(b, a % b);
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
vector<bool> prime(1000005, true);
vector<long long int> v;
void sieve(long long int n) {
  prime[1] = false;
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int i = 2; i <= n; i++) {
    if (prime[i] == true) v.push_back(i);
  }
}
int BIT[1000];
void update(int x, int delta) {
  int n;
  for (; x <= n; x += x & -x) BIT[x] += delta;
}
int query(int x) {
  int sum = 0;
  for (; x > 0; x -= x & -x) sum += BIT[x];
  return sum;
}
inline long long int add(long long int a, long long int b) {
  return ((a % mod) + (b % mod)) % mod;
}
inline long long int sub(long long int a, long long int b) {
  return ((a % mod) - (b % mod) + mod) % mod;
}
inline long long int mul(long long int a, long long int b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long int recur(long long int idx, long long int sum,
                    vector<pair<long long int, long long int> >& v,
                    vector<long long int>& b, vector<long long int>& pre,
                    vector<long long int>& dp) {
  if (idx == b.size()) return 0;
  if (dp[idx] != -1) return dp[idx];
  long long int temp = INT_MAX;
  temp = min(temp, recur(idx + 1, sum, v, b, pre, dp) + b[idx]);
  for (int i = 0; i < v.size(); i++) {
    long long int x = v[i].first;
    long long int y = v[i].second;
    if (idx + x - 1 >= b.size()) continue;
    long long int calc = pre[idx + x - 1] - pre[idx + y - 1];
    temp = min(temp, recur(idx + x, sum, v, b, pre, dp) + calc);
  }
  dp[idx] = temp;
  return temp;
}
long long int find(long long int u, vector<long long int>& parent) {
  if (u == parent[u])
    return u;
  else
    return parent[u] = find(parent[u], parent);
}
void unio(long long int u, long long int v, vector<long long int>& parent,
          vector<long long int>& ran) {
  u = find(u, parent);
  v = find(v, parent);
  if (u == v) return;
  if (ran[u] >= ran[v]) {
    parent[v] = u;
    ran[u] += ran[v];
  } else {
    parent[u] = v;
    ran[v] += ran[u];
  }
}
long long int dfs(long long int src, long long int p, vector<long long int>& a,
                  vector<pair<long long int, long long int> > adj[],
                  vector<long long int>& dp) {
  long long int can1 = 0;
  long long int can2 = 0;
  vector<pair<long long int, long long int> >::iterator it;
  for (it = adj[src].begin(); it != adj[src].end(); it++) {
    if (((*it).first == p)) continue;
    long long int st =
        max(0LL, dfs((*it).first, src, a, adj, dp) - (*it).second);
    if (st > can1) {
      can2 = can1;
      can1 = st;
    } else if (st > can2) {
      can2 = st;
    }
  }
  dp[src] = a[src] + can1 + can2;
  return (max(can1, can2) + a[src]);
}
struct comp1 {
  bool operator()(pair<long long int, long long int>& temp1,
                  pair<long long int, long long int>& temp2) {}
};
bool comp2(pair<long long int, long long int>& temp1,
           pair<long long int, long long int>& temp2) {
  return ((temp1.first < temp2.first) ||
          ((temp1.first == temp2.first) && (temp1.second < temp2.second)));
}
long long int getinv(long long int temp) { return power(temp, mod - 2, mod); }
long long int calc(long long int a, long long int b) {
  long long int ret = 0;
  ret = add(ret, power(2LL, a, mod));
  ret = add(ret, power(2LL, b, mod));
  ret = sub(ret, 1LL);
  return ret;
}
int main() {
  long long int n;
  cin >> n;
  map<pair<long long int, long long int>, long long int> m;
  long long int temp1 = 0;
  long long int temp2 = 0;
  long long int temp3 = 0;
  for (long long int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      temp1++;
      continue;
    } else if (a == 0) {
      temp2++;
      continue;
    } else if (b == 0) {
      temp3++;
      continue;
    }
    long long int c1 = abs(a);
    long long int c2 = abs(b);
    long long int g = gc(c1, c2);
    c1 /= g;
    c2 /= g;
    if ((a < 0 && b < 0) || (a > 0 && b > 0)) {
      a = c1;
      b = c2;
    }
    if (a > 0 && b < 0) {
      a = -c1;
      b = c2;
    }
    if (a < 0 && b > 0) {
      a = -c1;
      b = c2;
    }
    m[make_pair(a, b)]++;
  }
  map<pair<long long int, long long int>, long long int>::iterator it;
  vector<pair<long long int, long long int> > v;
  set<pair<long long int, long long int> > s;
  for (it = m.begin(); it != m.end(); it++) {
    long long int one = ((it->first).first);
    long long int two = ((it->first).second);
    if (s.find(make_pair(one, two)) != s.end()) continue;
    long long int req1 = two;
    long long int req2 = one;
    if (one < 0) {
      req2 = -req2;
    }
    if (one > 0) {
      req1 = -req1;
    }
    long long int temp1 = (it->second);
    long long int temp2 = 0;
    if (m.find(make_pair(req1, req2)) != m.end()) {
      temp2 = m[make_pair(req1, req2)];
      s.insert(make_pair(req1, req2));
    }
    s.insert(make_pair(one, two));
    v.push_back(make_pair(temp1, temp2));
  }
  v.push_back(make_pair(temp2, temp3));
  long long int ans = 0;
  long long int last1 = v[v.size() - 1].first;
  long long int last2 = v[v.size() - 1].second;
  ans = add(ans, power(2LL, last1, mod));
  ans = add(ans, power(2LL, last2, mod));
  ans = sub(ans, 1LL);
  ans = sub(ans, 1LL);
  long long int prod = calc(last1, last2);
  for (long long int i = v.size() - 2; i >= 0; i--) {
    long long int last1 = v[i].first;
    long long int last2 = v[i].second;
    long long int temp1 = power(2LL, last1, mod);
    temp1 = sub(temp1, 1LL);
    long long int temp2 = power(2LL, last2, mod);
    temp2 = sub(temp2, 1LL);
    ans = add(ans, mul(temp1, prod));
    ans = add(ans, mul(temp2, prod));
    long long int ret = calc(last1, last2);
    prod = mul(prod, ret);
  }
  cout << ans << endl;
}
