def pow(x, n, m):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= m
        x *= x
        x %= m
        n //= 2

    return (K * x) % m
def main():
    import sys
    from collections import Counter
    mod=1000000007
    N=int(sys.stdin.readline())
    L=[0]*N
    for i in range(N):
        A,B=list(map(int,sys.stdin.readline().split()))
        L[i]=A*B

    dic=Counter(L)
    print(dic)

    free_count=0
    L=[]
    for key,val in dic.items():
        if -key in dic.keys():
            if key>0:
                L.append((val,dic[-key]))     
        else:
            free_count+=val
    r=pow(2,free_count,mod)
    for a,b in L:
        r*=(pow(2,a,mod)+pow(2,b,mod)-1)%mod
        r%=mod

    print(r-1)#全部0っていうのは除く

main()