import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.concurrent.PriorityBlockingQueue;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        long[][] a = new long[n][2];

        HashMap<Long, Long> data = new HashMap<Long, Long>();
        ArrayList<Long[]> keys = new ArrayList<Long[]>();

        for (int i = 0; i < n; i++) {
            long ma = sc.nextLong();
            long mb = sc.nextLong();

            long mdx = Math.abs(ma);
            long mdy = Math.abs(mb);

            Long[] mcomb;

            if(ma == 0 && mb == 0){
                mcomb = new Long[]{0l, 0l};
            }else if(ma == 0){
                mcomb = new Long[]{0l, 1l};
            }else if(mb == 0){
                mcomb = new Long[]{1l, 0l};
            }else{
                long tmp;
                if(mdy > mdx){
                    tmp = mdx;
                    mdx = mdy;
                    mdy = tmp;
                }
            
                while((tmp = mdx % mdy) != 0){
                    mdx = mdy;
                    mdy = tmp;
                }

                if(mb < 0){
                    ma = -ma;
                    mb = -mb;
                }

                mcomb = new Long[]{ma / mdy, mb / mdy};

            }

            if(data.containsKey(makeKey(mcomb))){
                data.put(makeKey(mcomb), data.remove(makeKey(mcomb)) + 1);
            }else{
                data.put(makeKey(mcomb), 1L);
                keys.add(mcomb);
            }
        }

        final long DIV = 1000000007;

        int size = 1000100;
        long[] pow2 = new long[size];
        pow2[0] = 1;

        for (int i = 1; i < size; i++) {
            pow2[i] = pow2[i-1] * 2;
            pow2[i] %= DIV;
        }

        ArrayList<Long[]> pair = new ArrayList<Long[]>();
        long nonpair = 0;

        Long[] data00 = new Long[]{0l, 0l};
        Long[] data01 = new Long[]{0l, 1l};
        Long[] data10 = new Long[]{1l, 0l};



        for (int i = 0; i < keys.size(); i++) {
            Long[] mcomb = keys.get(i);

            if(!data.containsKey(makeKey(mcomb))) continue;

            if((mcomb[0] == 0 && mcomb[1] == 0) || (mcomb[0] == 0 && mcomb[1] == 1) || (mcomb[0] == 1 && mcomb[1] == 0)) continue;

            Long[] t1 = new Long[]{mcomb[1], -mcomb[0]};
            Long[] t2 = new Long[]{-mcomb[1], mcomb[0]};

            long mmin = 0;
            if(data.containsKey(makeKey(t1))){
                pair.add(new Long[]{data.remove(makeKey(mcomb)), data.remove(makeKey(t1))});
            }else if(data.containsKey(makeKey(t2))){
                pair.add(new Long[]{data.remove(makeKey(mcomb)), data.remove(makeKey(t2))});
            }else{
                nonpair += data.remove(makeKey(mcomb));
            }
        }

        if(data.containsKey(makeKey(data01)) && data.containsKey(makeKey(data10))){
            pair.add(new Long[]{data.remove(makeKey(data01)), data.remove(makeKey(data10))});
        }
        
        long ans = 0;
        if(pair.size() > 0 || nonpair > 0) ans = 1;
        ans *= pow2[(int)nonpair];
        for (int i = 0; i < pair.size(); i++) {
            long mans = 0;
            mans += pow2[(int)(long)pair.get(i)[0]];
            mans %= DIV;
            mans += pow2[(int)(long)pair.get(i)[1]];
            mans %= DIV;
            if(mans > 0) mans--;
            ans *= mans;
            ans %= DIV;
        }
        if(pair.size() > 0 || nonpair > 0) ans--;

        if(data.containsKey(makeKey(data00))){
            ans += data.remove(makeKey(data00));
            ans %= DIV;
        }

        System.out.println(ans);
    }

    public static long makeKey(Long[] ll){
        return ll[0] * 1000000000 + ll[1];
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

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

}
