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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

public class Main {
    static In in = new In();
    static Out out = new Out();
    static final long mod = 1000000007;
    static final long inf = 0x1fffffffffffffffL;
    static final int iinf = 0x3fffffff;
    static final int[] da = {-1, 0, 1, 0, -1, 1, 1, -1, -1};

    void solve() {
        int n = in.nextInt();
        long[] pow = new long[n + 1];
        pow[0] = 1;
        for (int i = 1; i <= n; i++) {
            pow[i] = pow[i - 1] * 2 % mod;
        }
        Map<Pair, Integer> neg = new HashMap<>();
        Map<Pair, Integer> pos = new HashMap<>();
        int zz = 0, az = 0, bz = 0;
        for (int i = 0; i < n; i++) {
            long a = in.nextLong();
            long b = in.nextLong();

            if (a == 0 && b == 0) {
                zz++;
            } else if (a == 0) {
                az++;
            } else if (b == 0) {
                bz++;
            } else {
                long gcd = gcd(Math.abs(a), Math.abs(b));
                a /= gcd;
                b /= gcd;
                if (a < 0 == b < 0) {
                    pos.merge(new Pair(Math.abs(a), Math.abs(b)), 1, Integer::sum);
                } else {
                    neg.merge(new Pair(Math.abs(b), Math.abs(a)), 1, Integer::sum);
                }
            }
        }
        long ans = 1;
        for (Map.Entry<Pair, Integer> entry : neg.entrySet()) {
            if (pos.containsKey(entry.getKey())) {
                int a = pos.get(entry.getKey());
                int b = entry.getValue();
                ans = ans * (((pow[a] + pow[b]) % mod + mod - 1) % mod) % mod;
            } else {
                int a = entry.getValue();
                ans = ans * pow[a] % mod;
            }
        }
        for (Map.Entry<Pair, Integer> entry : pos.entrySet()) {
            if (!neg.containsKey(entry.getKey())) {
                int a = entry.getValue();
                ans = ans * pow[a] % mod;
            }
        }
        ans = ans * (((pow[az] + pow[bz]) % mod + mod - 1) % mod) % mod;
        ans = ans + zz;
        out.println((ans + mod - 1) % mod);
    }

    long gcd(long a, long b) {
        return 0 < b ? gcd(b, a % b) : a;
    }

    long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class Pair {
    long a;
    long b;

    public Pair(long a, long b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Pair pair = (Pair)o;

        if (a != pair.a) {
            return false;
        }
        return b == pair.b;
    }

    @Override
    public int hashCode() {
        int result = (int)(a ^ (a >>> 32));
        result = 31 * result + (int)(b ^ (b >>> 32));
        return result;
    }

    @Override
    public String toString() {
        return "Pair{" + "a=" + a + ", b=" + b + '}';
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private PrintWriter out = new PrintWriter(System.out);
    boolean autoFlush = false;

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(int[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int i : a) {
            joiner.add(Integer.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void println(long[] a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (long i : a) {
            joiner.add(Long.toString(i));
        }
        out.println(joiner);
        if (autoFlush) {
            out.flush();
        }
    }

    void flush() {
        out.flush();
    }
}
