using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var dic = new Dictionary<Fraction, int>();
            for (int i = 0; i < n; i++)
            {
                long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
                var frac = new Fraction(input[0], input[1]);
                if (dic.ContainsKey(frac)) dic[frac]++;
                else dic.Add(frac, 1);
            }

            int count = 0;
            ModInt product = 1;
            foreach (var kv in dic)
            {
                if (kv.Key.IsPositive()) continue;
                var rfrac = kv.Key.Reversed();
                if (!dic.ContainsKey(rfrac)) continue;
                int x = kv.Value;
                int y = dic[rfrac];
                count += x + y;
                product *= ModInt.Pow(2, x) + ModInt.Pow(2, y) - 1;
            }

            product *= ModInt.Pow(2, n - count);
            Console.WriteLine((int) product - 1);
        }
    }

    struct Fraction
    {
        long deno;
        long nume;
        public Fraction(long deno, long nume)
        {
            this.deno = deno;
            this.nume = nume;
            Reduce();
        }
        void Reduce()
        {
            long gcd = MyMath.Gcd(Math.Abs(deno), Math.Abs(nume));
            if (deno < 0)
            {
                deno /= -gcd;
                nume /= -gcd;
            }
            else
            {
                deno /= gcd;
                nume /= gcd;
            }
        }
        public Fraction Reversed() => new Fraction(-nume, deno);
        public bool IsPositive() => nume < 0 ? false : true;
    }
  
    struct ModInt
    {
        const int MOD = 1000000007;
        long value;

        public ModInt(long value) => this.value = value;
        public static implicit operator ModInt(long a) => new ModInt(a % MOD + (a < 0 ? MOD : 0));
        public static explicit operator int(ModInt a) => (int) a.value;

        public static ModInt operator +(ModInt a, ModInt b) => a.value + b.value;
        public static ModInt operator -(ModInt a, ModInt b) => a.value - b.value;
        public static ModInt operator *(ModInt a, ModInt b) => a.value * b.value;

        public static ModInt Pow(ModInt a, int n)
        {
            if (n == 0) return 1;
            if (n == 1) return a;
            var p = Pow(a, n / 2);
            return p * p * Pow(a, n % 2);
        }
    }

    class MyMath
    {
        public static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
    }
}