#include <bits/stdc++.h>
using namespace std;
using vint = vector<long long>;
using vvint = vector<vint>;
using pint = pair<long long, long long>;
using vpint = vector<pint>;
template <typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr long long DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr long long DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
long long gcd(long long a, long long b) {
  while (b) {
    swap(a %= b, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
template <typename T>
void fin(T mes) {
  cout << mes << endl;
  exit(0);
}
template <typename T, typename U>
bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T, typename U>
bool chmin(T &a, const U &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
  os << "(" << rhs.first << ", " << rhs.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &rhs) {
  os << "{";
  for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
    os << *itr << (next(itr) != rhs.end() ? ", " : "");
  }
  os << "}";
  return os;
}
struct setup {
  static constexpr long long PREC = 20;
  setup() {
    cout << fixed << setprecision(PREC);
    cerr << fixed << setprecision(PREC);
  };
} setup;
template <long long MOD = 1000000007>
struct mod_int {
  long long val;
  mod_int(long long val_ = 0) : val(val_ % MOD) {
    if (val < 0) {
      val += MOD;
    }
  }
  bool operator==(const mod_int &rhs) const { return val == rhs.val; }
  bool operator!=(const mod_int &rhs) const {
    return std::rel_ops::operator!=(*this, rhs);
  }
  mod_int &operator+=(const mod_int &rhs) {
    if ((val += rhs.val) >= MOD) {
      val -= MOD;
    }
    return *this;
  }
  mod_int &operator-=(const mod_int &rhs) {
    if ((val += MOD - rhs.val) >= MOD) {
      val -= MOD;
    }
    return *this;
  }
  mod_int &operator*=(const mod_int &rhs) {
    val = (long long)((long long)val * rhs.val % MOD);
    return *this;
  }
  mod_int &operator/=(const mod_int &rhs) { return *this *= rhs.inv(); }
  mod_int operator+() const { return *this; }
  mod_int operator-() const { return -val; }
  mod_int operator++() { return *this += 1; }
  mod_int operator--() { return *this -= 1; }
  mod_int operator++(signed) {
    const mod_int ret(*this);
    ++*this;
    return ret;
  }
  mod_int operator--(signed) {
    const mod_int ret(*this);
    --*this;
    return ret;
  }
  mod_int operator+(const mod_int &rhs) const { return mod_int(*this) += rhs; }
  mod_int operator-(const mod_int &rhs) const { return mod_int(*this) -= rhs; }
  mod_int operator*(const mod_int &rhs) const { return mod_int(*this) *= rhs; }
  mod_int operator/(const mod_int &rhs) const { return mod_int(*this) /= rhs; }
  mod_int inv() const {
    long long a = val, b = MOD, x = 1, u = 0;
    while (b) {
      long long t = a / b;
      std::swap(a -= t * b, b);
      std::swap(x -= t * u, u);
    }
    return x;
  }
  mod_int pow(long long n) const {
    if (n < 0) {
      return pow(-n).inv();
    }
    mod_int ret = 1, mul = *this;
    while (n) {
      if (n & 1) {
        ret *= mul;
      }
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend std::istream &operator>>(std::istream &is, mod_int &rhs) {
    long long v;
    is >> v;
    rhs = v;
    return is;
  }
  friend std::ostream &operator<<(std::ostream &os, const mod_int &rhs) {
    return os << rhs.val;
  }
  struct combination {
    std::vector<mod_int> fact{1, 1}, f_inv{1, 1}, inv{0, 1};
    void calc(long long n) {
      while (fact.size() <= n) {
        long long i = fact.size();
        fact.push_back(fact[i - 1] * i);
        inv.push_back(-inv[MOD % i] * (MOD / i));
        f_inv.push_back(f_inv[i - 1] * inv[i]);
      }
    }
    mod_int P(long long n, long long r) {
      return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[n - r]);
    }
    mod_int C(long long n, long long r) {
      return r < 0 || n < r ? 0 : (calc(n), fact[n] * f_inv[r] * f_inv[n - r]);
    }
    mod_int H(long long n, long long r) { return C(n + r - 1, r); }
  };
};
signed main() {
  long long N;
  cin >> N;
  vint A(N), B(N);
  for (long long i = 0; i < (N); i++) {
    cin >> A[i] >> B[i];
  }
  using mint = mod_int<>;
  using m0 = mod_int<>;
  using m1 = mod_int<998244353>;
  map<pint, long long> mp;
  long long acnt = 0, bcnt = 0, xcnt = 0;
  for (long long i = 0; i < (N); i++) {
    if (A[i] == 0 && B[i] == 0) {
      xcnt++;
      continue;
    }
    if (A[i] == 0) {
      acnt++;
      continue;
    }
    if (B[i] == 0) {
      bcnt++;
      continue;
    }
    m0 cur0 = m0(A[i]) / B[i];
    m1 cur1 = m1(A[i]) / B[i];
    mp[{cur0.val, cur1.val}]++;
  }
  set<pint> st;
  mint ans = 1;
  for (auto p : mp) {
    m0 a0 = p.first.first;
    m0 b0 = m0(-1) / a0;
    m1 a1 = p.first.second;
    m1 b1 = m1(-1) / a1;
    if (st.count({a0.val, a1.val}) != 0) {
      continue;
    }
    st.insert({b0.val, b1.val});
    long long ca = mp[{a0.val, a1.val}];
    long long cb = mp[{b0.val, b1.val}];
    cerr << "ca"
            " = "
         << (ca) << endl,
        cerr << "cb"
                " = "
             << (cb) << endl;
    ans *= mint(2).pow(ca) + mint(2).pow(cb) - 1;
  }
  ans *= mint(2).pow(acnt) + mint(2).pow(bcnt) - 1;
  ans += xcnt;
  cout << ans - 1 << endl;
}
