import numpy as np
from collections import deque, defaultdict

def main():
    N = int(input())
    M = np.zeros((N, 2))
    for i in range(N):
        a, b = tuple(int(c) for c in input().split(' '))
        M[i, 0] = a
        M[i, 1] = b
    
    d = M @ M.T
    kirai = defaultdict(set)
    suki = defaultdict(set)
    for i in range(N):
        for j in range(i+1, N):
            if d[i, j] == 0:
                kirai[i].add(j)
                kirai[j].add(i)
            else:
                suki[i].add(j)
                suki[j].add(i)
                #continue
    q = deque((0, i) for i in suki[0])
    for j in range(1, N):
        l = [(j, i) for i in suki[j] if j < i]
        for left, right in l:
            q.append((left, right))
    ans = 0
    ans += len(q)
    while(True):
        #print(q)
        if(len(q) <= 0):
            break
        cur, acc = q.popleft()
        #print(q.popleft())
        if cur > acc:
            continue
        else:
            l = [(acc, t) for t in suki[acc] if acc < t]
            ans += len(l)
            for left, right in l:
                q.append((left, right))
    print(ans % 1000000007)

if __name__ == "__main__":
    main()