We have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.

We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.

The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.

In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Constraints

* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* -10^{18} \leq A_i, B_i \leq 10^{18}

Input

Input is given from Standard Input in the following format:


N
A_1 B_1
:
A_N B_N


Output

Print the count modulo 1000000007.

Examples

Input

3
1 2
-1 1
2 -1


Output

5


Input

10
3 2
3 2
-1 1
2 -1
-3 -9
-8 12
7 7
8 1
8 2
8 4


Output

479
import java.io.*;
import java.math.*;
import java.util.*;

class Pair{
    long n1, n2;
    public Pair(long n1, long n2)
    {
        this.n1 = n1;
        this.n2 = n2;
    }

    @Override
    public String toString() {
        return "Pair{" +
                "n1=" + n1 +
                ", n2=" + n2 +
                '}';
    }
}
public class Main{

    static long MOD = 1000000007L;
    static long [] fac;
    static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    static long lMax = 0x3f3f3f3f3f3f3f3fL;
    static int iMax = 0x3f3f3f3f;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
           int n = sc.nextInt();
           long a[] = new long[n], b[] = new long[n];
           long ans = 1L;
           long zzCnt = 0L, azCnt = 0L, bzCnt = 0L;
           HashMap <String, Pair> cnt = new HashMap();
           ArrayList <Pair> list = new ArrayList();
           for(int i = 0; i < n; i++)
           {
               a[i] = sc.nextLong();
               b[i] = sc.nextLong();
               if(a[i] == 0 && b[i] == 0) zzCnt++;
               else if(a[i] == 0) azCnt++;
               else if(b[i] == 0) bzCnt++;
               else
               {
                   long g = gcd(Math.abs(a[i]), Math.abs(b[i]));
                   a[i] /= g;
                   b[i] /= g;
                   if((a[i] > 0 && b[i] > 0) || a[i] < 0 && b[i] < 0)
                   {
                       String code = Math.abs(a[i]) + "#" + Math.abs(b[i]);
                       if(cnt.get(code) == null)
                           cnt.put(code, new Pair(1, 0));
                       else
                           cnt.get(code).n1++;
                   }
                   else
                   {
                       String code = Math.abs(b[i]) + "#" + Math.abs(a[i]);
                       if(cnt.get(code) == null)
                           cnt.put(code, new Pair(0, 1));
                       else
                           cnt.get(code).n2++;
                   }
               }
           }
           for(Pair p : cnt.values()) list.add(p);
           list.add(new Pair(azCnt, bzCnt));
           for(Pair p : list)
               ans = (ans * ( (quickPOW(2L, p.n1) + quickPOW(2L, p.n2) - 1) % MOD)) % MOD;
           ans = (ans + zzCnt + MOD - 1) % MOD;
           out.println(ans);
        }
        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long gcd(long a, long b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}