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.util.*;
import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = (int) 1e9 + 7;
	static long inf = (long) 1e16;
	static int[] col;
	static int n, m;
	static ArrayList<Integer>[] ad;
	static int[][][] memo;
	static ArrayList<Integer> h;
	static int[][] grid;
	static char[] a;
	static boolean[] tak;
	static boolean f;
	static int N1, P1, M1;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		n = sc.nextInt();
		int zeros = 0;
		int rr = 0;
		int ll = 0;
		long ans = 1;
		TreeMap<pair, Integer> pos = new TreeMap<>();
		TreeMap<pair, Integer> neg = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			if ((a > 0 && b > 0) || (b < 0 && a < 0)) {
				a = Math.max(a, -a);
				b = Math.max(b, -b);
				long d = gcd(a, b);
				a /= d;
				b /= d;
				pos.put(new pair(a, b), pos.getOrDefault(new pair(a, b), 0) + 1);
			} else if (a == b && b == 0) {
				zeros++;
			} else if (b == 0 && a != 0) {
				rr++;
			} else if (b != 0 && a == 0) {
				ll++;
			} else {
				a = Math.max(a, -a);
				b = Math.max(b, -b);
				long d = gcd(a, b);
				a /= d;
				b /= d;
				neg.put(new pair(a, b), neg.getOrDefault(new pair(a, b), 0) + 1);
			}
		}
		n -= zeros;
		if (rr > 0 && ll > 0) {
			n -= rr;
			n -= ll;
			ans = (ans * ((modPow(2, ll) + modPow(2, rr) - 1 + mod) % mod)) % mod;
		}
		for (pair t : pos.keySet()) {
			if (neg.containsKey(new pair(t.number, t.to))) {
				int p = pos.get(t);
				int ne = neg.get(new pair(t.number, t.to));
				ans = (ans * ((modPow(2, p) + modPow(2, ne) - 1 + mod) % mod)) % mod;
				n -= p;
				n -= ne;
			}
		}
		ans=ans*modPow(2, n)%mod;
		System.out.println((ans - 1 + zeros + mod) % mod);
		out.flush();
	}

	static class pair implements Comparable<pair> {
		long to;
		long number;

		pair(long t, long n) {
			number = n;
			to = t;
		}

		public String toString() {
			return to + " " + number;
		}

		@Override
		public int compareTo(pair o) {
			if (to == o.to)
				return Long.compare(o.number, number);
			return Long.compare(to, o.to);
		}

	}

	static long gcd(long a, long b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static long modPow(long a, long e)

	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res = (res * a) % mod;
			a = (a * a) % mod;
			e >>= 1;
		}
		return res;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}