import * as fs from 'fs';

const readString = (() => {
  const input = fs.readFileSync(0).toString();
  const words = input.split(/[ \n]/);
  let i = 0;
  return () => words[i++] || '';
})();
const readInt = () => parseInt(readString(), 10);
const readBigInt = () => BigInt(readString());

const gcd = (a: bigint, b: bigint) => {
  const _gcd = (a: bigint, b: bigint): bigint => {
    const q = a % b;
    return q === 0n ? b : _gcd(b, q);
  };
  return a > b ? _gcd(a, b) : _gcd(b, a);
};

const abs = (a: bigint) => a > 0n ? a : -a;

(function main() {
  const N = readInt();

  let zero: number = 0;
  const groups: { [a: string]: { [b: string]: number } } = {};
  Array.from({ length: N }, () => {
    let A = readBigInt();
    let B = readBigInt();
    if (A === 0n && B === 0n) {
      zero++;
    } else if (A === 0n) {
      groups['0'] = groups['0'] || {};
      groups['0']['1'] = groups['0']['1'] || 0;
      groups['0']['1']++;
    } else if (B === 0n) {
      groups['1'] = groups['1'] || {};
      groups['1']['0'] = groups['1']['0'] || 0;
      groups['1']['0']++;
    } else {
      const n = gcd(abs(A), abs(B));
      A /= n;
      B /= n;
      if (A < 0) {
        A *= -1n;
        B *= -1n;
      }

      const as = A.toString();
      const bs = B.toString();
      groups[as] = groups[as] || {};
      groups[as][bs] = groups[as][bs] || 0;
      groups[as][bs]++;
    }
  });

  console.log(JSON.stringify(groups, null, 2));
  const mod = 1000000007;

  let result: number = 1;
  for (const A of Object.keys(groups)) {
    const a = BigInt(A);
    for (const B of Object.keys(groups[A])) {
      const b = BigInt(B);
      if (b < 0 && groups[(-b).toString()] && groups[(-b).toString()][A]) continue;

      const xn = groups[A][B];
      const yn = (groups[B] && groups[B][(-a).toString()]) || 0;

      let tmp: number = 0;
      if (xn) {
        let xx = 1;
        for (let i = 0; i < xn; i++) {
          xx *= 2;
          if (xx > mod) xx %= mod;
        }
        xx -= 1;
        tmp += xx;
      }

      if (yn) {
        let yy = 1;
        for (let i = 0; i < yn; i++) {
          yy *= 2;
          if (yy > mod) yy %= mod;
        }
        yy -= 1;
        tmp += yy;
      }

      tmp++;
      if (tmp > mod) tmp %= mod;
      console.log(tmp);

      result *= tmp;
      if (result > mod) result %= mod;
    }
  }

  result += zero - 1;
  if (result > mod) result %= mod;

  console.log(result.toString());
})();
