Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c
        
elif ans[0] == 0 and n >= 2:
    print(-1)
    exit()
    
elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)


### FIXED CODE ###

n, m = map(int, input().split())

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c

if ans[0] == 0 and n >= 2:
    print(-1)
    exit()

elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)
s=input()

if s[0]!==s[1] or s[1]==s[2]:
  print("Yes")
  
else :
  print("No")


### FIXED CODE ###

s=input()
if s[0]==s[1] and s[1]==s[2]:
  print("No")
  
else :
  print("Yes")
import math
 
n = input()
 
px = 0
py = 0
qx = 100
qy = 0
 
def koch(n, px, py, qx, qy):
 if n == 0:
  return
  
 s.x = (px*2+qx*1)/3
 s.y = (py*2+qy*1)/3
 t.x = (px*1+qx*2)/3
 t.y = (py*1+qy*2)/3
 u.x = (t.x-s.x)*cos(pi/3) - (t.y-s.y)*sin(pi/3) + s.x
 u.y = (t.x-s.x)*sin(pi/3) - (t.y-s.y)*cos(pi/3) + s.y
 
 koch(n-1, px, py, s.x, s.y)
 print s.x, s.y
 koch(n-1, s.x, s.y, u.x, s.y)
 print u.x, u.y
 koch(n-1, u.x, u.y, t.x, t.y)
 print t.x, t.y
 koch(n-1, t.x, t.u, qx, qy)
 
print px, py
koch(n, px, py, qx, qy)
print qx, qy

### FIXED CODE ###

import math
          
def koch(n, h, i, j, k):
 if n == 0:
  return
           
 sx = (h*2+j)/3
 sy = (i*2+k)/3
 tx = (h+j*2)/3
 ty = (i+k*2)/3
 ux = (tx-sx)*math.cos(math.pi/3) - (ty-sy)*math.sin(math.pi/3) + sx
 uy = (tx-sx)*math.sin(math.pi/3) + (ty-sy)*math.cos(math.pi/3) + sy
          
 koch(n-1, h, i, sx, sy)
 print sx, sy
 koch(n-1, sx, sy, ux, uy)
 print ux, uy
 koch(n-1, ux, uy, tx, ty)
 print tx, ty
 koch(n-1, tx, ty, j, k)
   
n = input()
          
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
          
print px, py
koch(n, px, py, qx, qy)
print qx, qy
from fractions import gcd
a,b,k = map(int,input().split())
x = gcd(a,b)
now = 1
for i in range(x-1,-1,-1):
    if x%i == 0:now += 1
    if now == k:
        print(i)
        exit()

### FIXED CODE ###

import fractions
a,b,k = map(int,input().split())
q = fractions.gcd(a,b)
count = 0
for i in range(q,-1,-1):
    if q%i == 0:
        count += 1
        if count == k:
            print(i)
            exit()
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
diffs = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
max_diff = 0
for diff in diffs:
    max_diff= max(max_diff, max(diff))
r_k = max_diff*(H+W)
dp = [[[False] * r_k for _ in range(W + 1)] for _ in range(H + 1)]
dp[0][0][0] = True
dp[1][0][0] = True
dp[0][1][0] = True
for i in range(H):
    for j in range(W):
        diff = diffs[i][j]
        for k in range(r_k):
            dp[i + 1][j + 1][abs(k - diff)] = dp[i + 1][j][k] or dp[i][j +
                                                                       1][k] or dp[i + 1][j + 1][abs(k - diff)]
            if k + diff < r_k:
                dp[i + 1][j + 1][k + diff] = dp[i + 1][j][k] or dp[i][j +
                                                                      1][k] or dp[i + 1][j + 1][k+diff]

for k in range(r_k):
    if dp[H][W][k]:
        print(k)
        break


### FIXED CODE ###

H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
diffs = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
max_diff = 0
for diff in diffs:
    max_diff = max(max_diff, max(diff))
r_k = max_diff*(H+W)//2+1
dp = [[[False] * r_k for _ in range(W)] for _ in range(H)]
dp[0][0][0] = True
for i in range(H):
    for j in range(W):
        diff = diffs[i][j]
        dp_ = dp[i][j]
        if j < W-1:
            dpj = dp[i][j + 1]
            for k in range(r_k):
                if dp_[k] == True:
                    dpj[abs(k - diff)] = True
                    if k+diff<r_k:
                        dpj[k + diff] = True
        if i < H - 1:
            dpi = dp[i + 1][j]
            for k in range(r_k):
                if dp_[k] == True:
                    dpi[abs(k-diff)] = True
                    if k+diff < r_k:
                        dpi[k + diff] = True

ans = pow(80, 3)
diff = diffs[H-1][W-1]
for k, flg in enumerate(dp[H - 1][W - 1]):
    if flg:
        ans = min(ans, abs(k-diff), k+diff)
print(ans)
N=int(input())
H=list(map(int,input().split()))

def cost(n):
    if n==1:
        return 0
    if n==2:
        return H[1]-H[0]
    else:
        ans=min(cost(n-2)+abs(H[n-1]-H[n-3]),cost(n-1)+abs(H[n-1]-H[n-2]))
    return ans

print(cost(N))

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
dp=[0]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))

print(dp[N-1])
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 
        2, 2, 5, 4, 1, 4, 1, 51]

index = input()
print(list[index+1])

### FIXED CODE ###

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 
        2, 2, 5, 4, 1, 4, 1, 51]

index = input()
index = int(index)
print(list[index-1])
miu = input().split()
sella = input()

for x in range(0, int(miu[0]):
	if x == int(miu[1]):
		print(sella[x].lower(), end='')
	else:
		print(sella[x], end='')

### FIXED CODE ###

miu = input().split()
sella = input()

for x in range(0, int(miu[0])):
	if x == int(miu[1])-1:
		print(sella[x].lower(), end='')
	else:
		print(sella[x], end='')
n, k = map(int, input().split())
a = list(map(int, input().split()))

zyun = [a[0]]
alr = [False]*n
alr[0] = True
crr = a[0]

key = True

while key:
    if not alr[crr - 1]:
        alr[crr - 1] = True
        crr = a[crr - 1]
        zyun.append(crr)
        continue
    else:
        index = crr - 1
        key = False


# print(zyun, index)
if a.index(a[index]) == 0:
    zyun1 = zyun
    zyun2 = zyun
else:
    zyun1 = zyun[:a.index(a[index]) + 1]
    zyun2 = zyun[a.index(a[index]) + 1:]

# print(zyun1, zyun2)

if len(zyun1) >= k:
    print(zyun1[k])
else:
    ind = (k - len(zyun1)) % len(zyun2)
    if ind == 0:
        print(zyun2[-1])
    else:
        print(zyun2[ind - 1])

### FIXED CODE ###

n, k = map(int, input().split())
a = [int(n) - 1 for n in input().split()]  # indexに合うように調整する
v = [-1] * n  # 到達してるかどうかを格納するリスト

D = [0]  # Dは循環するもののindexを格納する
v[0] = 0  # 初期スタート位置の到達ステータスは0

cur = a[0]  # 初期位置はindex=0
i = 1

while v[cur] == -1:
    D.append(cur)
    v[cur] = i # 到達済みに変更(iは何番目に到達したか）
    if k == i:  # 循環が発生する前にkの上限に達してしまった場合
        print(cur + 1)
        exit()

    i += 1
    cur = a[cur]

# 循環している場合を考える
k -= v[cur]  # 1回目の到達点を引く
k %= (i - v[cur])  # kを循環する回数で割った余りを考える = 循環した中でどれかという事が分かる

print(D[v[cur] + k] + 1)  # v[cur]で循環しない部分を表し、kで循環した中でどこかを表す
L,R = map(int,input().split())

if R - L >= 2018:
    print(0)
else:
    m = 2020
    for i in range(L,R):
        for j in range(i+1,R+1):
            mod = i * j % 2019
            if mod <= m:
                m = mod

print(m)

### FIXED CODE ###

L,R = map(int,input().split())

if R - L >= 2018:
    print(0)
else:
    min = 2020
    for i in range(L,R):
        for j in range(i+1,R+1):
            mod = i * j % 2019
            if mod <= min:
                min = mod
    print(min)
A,B = map(int, input().split())
if (A * B) % 2 == 0:
  print("Even")
else:
  plint("Odd")

### FIXED CODE ###

A,B = map(int, input().split())
if (A * B) % 2 == 0:
  print("Even")
else:
  print("Odd")
import sys
input = sys.stdin.readline

def main():
    s = list(input().rstrip())
    k = int(input())

    c = 0

    if s[0] == s[-1]:
        if s[0] == s[1]:
            s[0] = '2'
        else:
            s[-1] = '2'

        c += 1

    for i in range(len(s) - 1):
        if s[i] == s[i+1]:
            c += 1
            s[i+1] = '1'

    print(c*k)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    s = list(input().rstrip())
    k = int(input())


    if len(s) == 1:
        print(k//2)
    else:
        sa = s[:]

        c1 = 0
        c2 = 0

        for i in range(len(s) - 1):
            if sa[i] == sa[i+1]:
                c1 += 1
                sa[i+1] = '1'


        if sa[0] == sa[-1]:
            s[0] = '2'
            c2 += 1

            for i in range(len(s) - 1):
                if s[i] == s[i+1]:
                    c2 += 1
                    s[i+1] = '2'


            if s[-1] == sa[0]:
                print(c1 + c2*(k-1))
            elif s[-1] != sa[0]:
                if k % 2 == 0:
                    x = k // 2
                    print(c1*x + c2*x)
                else:
                    x = k // 2
                    print(c1*(x+1) + c2*x)
        else:
            print(c1*k)

if __name__ == '__main__':
    main()
a = int(input().strip())
print a*a

### FIXED CODE ###

# -*- coding: utf-8 -*-

r = int(input().strip())
print(r*r)
N, L = map(int, input().split())
Slist = list(input() for _ in range(N))
print(''.join(Slist.sort()))


### FIXED CODE ###

N, L = map(int, input().split())
Slist = list(input() for _ in range(N))
Slist.sort()
print(''.join(Slist))
N, X = map(int, input().split())
l = list(map(int, input().split()))
m=[]
from functools import reduce
from math import gcd
for i in l:
    m.append(abs(i-X))
print(reduce(gcd,m))

### FIXED CODE ###

from functools import reduce
from fractions import gcd
N,X=map(int,input().split())
x=[abs(X-int(i)) for i in input().split()]
print(reduce(gcd,x))
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
    exit()

p.sort()
print(p)
for i in range(n):
    if p[i] == x:
        index = i
        break

right = x + 1
for i in p[index + 1:]:
    print(i)
    if i != right:
        print('aaaa')
        print(right)
        break
    right += 1

left = x - 1
for i in reversed(p[:index]):
    print(i)
    if i != left:
        print('bbbb')
        print(left)
        break
    left -= 1

if x - left <= right - x:
    print(left)
else:
    print(right)

### FIXED CODE ###

x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
    exit()

p.sort()

if x not in p:
    print(x)
    exit()
    
for i in range(len(p)):
    #print(p[i])
    if p[i] == x:
        index = i
        break

right = x + 1
for i in p[index + 1:]:
    if i != right:
        break
    right += 1

left = x - 1
for i in reversed(p[:index]):
    if i != left:
        break
    left -= 1

if x - left <= right - x:
    print(left)
else:
    print(right)
#D - Friends
N,M = map(int,input().split())
par = [i for i in range(N+1)]
rank = [1] * (N + 1)

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]

def size(x):
    return par.count(find(x))

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    if x > y:
        x,y = y,x
    par[y] = x
    if par[x] == par[y]:
        rank[x] += 1
#    par[x] = y

print(par)
print(rank)
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b)
    print(par)
    print(rank)
group_count = 0

group_count = max(rank)

# 出力
print(group_count)


### FIXED CODE ###

#D - Friends
N,M = map(int,input().split())
par = [i for i in range(N)]
rank = [1] * (N)

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]

def size(x):
    return par.count(find(x))

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y : return 0
    if par[x] > par[y]:
        x,y = y,x
    par[y] = x
#    par[x] = x
    if par[x] == par[y]:
        rank[x] += rank[y]
#        rank[y] += rank[x]
#print(par)
#print(rank)
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b)
#    print(par)
#    print(rank)
group_count = 0

group_count = max(rank)

# 出力
print(group_count)
S = str(input())
K = int(input())

sub = set()
for i in range(1,min(K, len(S))+1):
    for j in range(len(S)-K+1):
        sub.add(S[j:j+i])
m=list(sub)
m.sort()
print(m[K-1])

### FIXED CODE ###

S = str(input())
K = int(input())
 
sub = set()
for i in range(1,min(K, len(S))+1):
    for j in range(len(S)-i+1):
        sub.add(S[j:j+i])
m=list(sub)
m.sort()
print(m[K-1])
#Bです
import sys
input=lambda: sys.stdin.readline().rstrip()
t=int(input())
for _ in range(t):
  c,d=map(int,input().split())
  X=[0]+[-int(i) for i in input().split()]
  edge=[[] for i in range(c)]
  E=[0]*d
  for i in range(d):
    u,v=map(int,input().split())
    edge[u-1].append([v-1,i])
    edge[v-1].append([u-1,i])
  
  D=[[] for i in range(c)]
  for i in range(1,c):
    D[X[i]].append(i)
  for i in range(1,c):
    if not D[i]:
      continue
    else:
      for goal in D[i]:
        t_root=0
        dist=float("inf")
        t_ind=0
        for root,ind in edge[goal]:
          if X[root]<dist:
            t_root=root
            dist=X[root]
            t_ind=ind
        E[t_ind]=i-dist
  for i in range(d):
    if E[i]==0:
      E[i]=str(10**6)
    else:
      E[i]=str(E[i])
  ans=" ".join(E)
  print("Case #"+str(_+1)+": "+ans)



### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
s,w=map(int,input().split())
if w>=s:
  print("unsafe")
else:
  print("safe")
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
ans = X[-1] - X[0]
d = []
for i in range(N-1):
    d.append(X[i+1]-X[i])
d.sort()
n = min(N-1,M-1)
for i in range(n):
    ans -= d[-i]
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
d = []
for i in range(M-1):
    d.append(X[i+1]-X[i])
d.sort()
n = min(M-1,N-1)
for i in range(n):
    d.pop()
ans = sum(d)
print(ans)
a,b=map(int,input().split())↲
d=0
c=a*3
if c>1:
  d=(c+b)//2
elif c==0 and b>1:
  d=b//2
print(d)↲

### FIXED CODE ###

a, p = map(int, input().split())
#print (int((a*3 + p) / 2))
#a,p=map(int,input().split())↲
print(int((a*3+p)/2))
a,b = input().split()

if a>=b:
  print(b＊int(a))
else:
  print(a＊int(b))


### FIXED CODE ###

li = input().split()

if li[0]>=li[1]:
  print(li[1] *int(li[0]))
else:
  print(li[0] *int(li[1]))
ab=input()
a=split()[0]
b=split()[1]
s=a*b
l=(a+b)*2
print("{0} {1}".format(s,l))


### FIXED CODE ###

ab=input()
a=int(ab.split()[0])
b=int(ab.split()[1])
s=a*b
l=(a+b)*2
print("{0} {1}".format(s,l))
import sys


if __name__ == "__main__":
    N = int(input())

    rates = [map(int, raw_input().split()) for i in range(N)]
    # tasks = np.array(tasks)
    normal_colors = int(3200/400)
    colors = [None] * normal_colors
    any = 0
    for rate in rates:
        if rate >= 3200:
            any +=1
        else:
            colors[rate/400] = 1
    print(sum(colors), sum(colors)+any)

### FIXED CODE ###

import sys


if __name__ == "__main__":
    N = int(input())

    rates = map(int, raw_input().split())
    # rates = [map(int, raw_input().split()) for i in range(N)]

    # tasks = np.array(tasks)
    normal_colors = int(3200/400)
    colors = [0] * normal_colors
    aaa = 0
    for rate in rates:
        if rate >= 3200:
            aaa +=1
        else:
            colors[rate/400] = 1

    print max(sum(colors),1), sum(colors)+aaa
import sys
input = sys.stdin.readline
def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    elif m == 3:
        print("bon")
if __name__ == "__main__":
    main()


### FIXED CODE ###


def main():
    N = input()
    N_l = list(N)
    m = int(N_l[-1])
    if m == 0 or m == 1 or m==6 or m==8:
        print("pon")
    elif m == 2 or m== 4 or m == 5 or m == 7 or m==9:
        print("hon")
    elif m == 3:
        print("bon")
if __name__ == "__main__":
    main()
a=int(input())
b=list(map(int,input().split()))
b.sort()
if b[(a/2)-1]==b[(a/2)]:
  print(0)
else:
  print(b[(a/2)]-b[(a/2)-1]-1)

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
b.sort()
if b[int(a/2)-1]==b[int(a/2)]:
  print(0)
else:
  print(b[int(a/2)]-b[int(a/2)-1])
print(*["YNeos"[(int(s)%sum(int(i))for i in s)>0::2]for s in[input()]])


### FIXED CODE ###

print(*["YNeos"[(int(s)%sum(int(i)for i in s))>0::2]for s in[input()]])
n,m=map(int,input().split())
a=[0 for i in range(m)]
for i in range(n):
  b=list(map(int,input().split()))
  for i in range(b[0]):
    a[b[i+1]]+=1
ans=0
for i in a:
  if i==n:
    ans+=1
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
a=[0 for i in range(m)]
for i in range(n):
  b=list(map(int,input().split()))
  for i in range(b[0]):
    a[b[i+1]-1]+=1
ans=0
for i in a:
  if i==n:
    ans+=1
print(ans)
import math
n,m=map(int,input().split())
# 1*mのうちnコを予め除いた残りで組み合わせの数を求められる
# (m-n+n-1)!/((m-n)!(n-1)!)
if m%n==0:
    print(m//n)
else:
    print(math.gcd(m//n,m%n))


### FIXED CODE ###

# できなかった
# a1,...,anがdivisorで割り切れる、すなわちdivisorはMの約数である
n,m=map(int,input().split())

divisors=[]
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        divisors.append(i)
        if i!=m//i:
            divisors.append(m//i)

divisors.sort(key=lambda x:-x)
# print(divisors)
for d in divisors:
    if d<=m//n:
        print(d)
        break
n,s = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
dif = []
for i in range(n-1):
    dif.append(x[i+1]-x[i])


difs = []
for i in range(n):
    difs.append(abs(s-x[i]))

res = min(min(dif),min(difs))
for i in range(res):
    flag = True
    for j in range(n-1):
        if dif[j]%(res-i)!=0:
            flag = False
            break
    if flag:
        res -= i
        break
            
print(res)

### FIXED CODE ###

n,s = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if n>1:
    dif = []
    for i in range(n-1):
        dif.append(x[i+1]-x[i])

    difs = []
    for i in range(n):
        difs.append(abs(s-x[i]))
    res = min(min(dif),min(difs))
    for i in range(res):
        flag = True
        for j in range(n-1):
            if dif[j]%(res-i)!=0:
                flag = False
                break
        if flag:
            res -= i
            break
                
    print(res)
else:
    print(abs(x[0]-s))
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if n % 3 != 0:
        print('No')
        return
    if num != 3 and cnt[0][1] !=3 and cnt[-1][1 != 3]:
        print('No')
        return
    print('Yes')

if __name__ == '__main__':
    main()


### FIXED CODE ###

import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    aset=set(a)

    if sum(a) == 0:
        print('Yes')
        return
    # if n % 3 != 0:
        # print('No')
        # return
    if len(cnt.most_common()) == 3:
        a1, a2, a3 = aset
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] == cnt.most_common()[2][1]  and a1 ^ a2 == a3:
            # print(cnt.most_common())
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if 3 * tmp_min == n and int(cnt.most_common()[1][0]) == 0:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()
A, B = list(map(int, input().split()))
if A <= 9 and B =< 9 :
	print(A * B)
else :
	print(-1)

### FIXED CODE ###

A, B = list(map(int, input().split()))
if A <= 9 and B <= 9 :
	print(A * B)
else :
	print(-1)
N = int(input())
W = list(map(int, input().split()))
l = sum(W)
r = 0
ans = l
for w in W:
    l -= w
    r += w
    ans = min(abs(r - l))

print(ans)

### FIXED CODE ###

N = int(input())
W = list(map(int, input().split()))
l = sum(W)
r = 0
ans = l
for w in W:
    l -= w
    r += w
    ans = min(abs(r - l), ans)

print(ans)
import sys
input = sys.stdin.readline
mod = 10**9 + 7
n = int(input())
ab = [[int(x) for x in input().split()] for _ in range(n)]
from collections import defaultdict, Counter
import math
double_zero_cnt = 0
a_zero_cnt = 0
b_zero_cnt = 0
d = defaultdict(list) # [a, b] ngのそれぞれの個数
a_b = []
for a, b in ab:
    if a == 0 and b == 0: 
        double_zero_cnt += 1
        continue
    elif a == 0:
        a_zero_cnt += 1
        continue
    elif b == 0:
        b_zero_cnt += 1
        continue
    g = math.gcd(a, b)
    a //= g
    b //= g
    if b < 0:
        b *= (-1)
        a *= (-1) # 必ずbは正
    a_b.append((a, b))
c = Counter(a_b)
key_list = list(c.keys())
for key in key_list:
    a, b = key
    if c[(-abs(b), abs(a))] != 0:
        d[(a, b)] = [c[(a, b)], c[(-abs(b), abs(a))]]
        c[(a, b)] = 0
ans = 1
used_cnt = double_zero_cnt
for key in d.keys():
    if d[key] == []:
        continue
    x, y = d[key]
    used_cnt += (x + y)
    mul = (pow(2, x, mod) + pow(2, y, mod) - 1) % mod
    ans *= mul
    ans %= mod
if a_zero_cnt > 0 and b_zero_cnt > 0:
    ans *= (pow(2, a_zero_cnt, mod) + pow(2, b_zero_cnt, mod) - 1)
    ans %= mod
    used_cnt += a_zero_cnt + b_zero_cnt
elif a_zero_cnt > 0:
    ans *= pow(2, a_zero_cnt, mod)
    ans %= mod
    used_cnt += a_zero_cnt
elif b_zero_cnt > 0:
    ans *= pow(2, b_zero_cnt, mod)
    ans %= mod
    used_cnt += b_zero_cnt
ans *= pow(2, n - (used_cnt), mod)
ans %= mod
ans -= 1
ans += double_zero_cnt
ans %= mod
print(ans)







### FIXED CODE ###

import sys
input = sys.stdin.readline
mod = 10**9 + 7
n = int(input())
ab = [[int(x) for x in input().split()] for _ in range(n)]
from collections import defaultdict, Counter
import math
double_zero_cnt = 0
a_zero_cnt = 0
b_zero_cnt = 0
d = defaultdict(list) # [a, b] ngのそれぞれの個数
a_b = []
for a, b in ab:
    if a == 0 and b == 0: 
        double_zero_cnt += 1
        continue
    elif a == 0:
        a_zero_cnt += 1
        continue
    elif b == 0:
        b_zero_cnt += 1
        continue
    g = math.gcd(a, b)
    a //= g
    b //= g
    if b < 0:
        b *= (-1)
        a *= (-1) # 必ずbは正
    a_b.append((a, b))
c = Counter(a_b)
key_list = list(c.keys())
for key in key_list:
    a, b = key
    if a < 0:
        a_ = a*(-1)
        b_ = b*(-1)
    else:
        a_ = a
        b_ = b
    if d[(-b_, a_)] != []:
        continue
    if c[(-b_, a_)] != 0:
        d[(a, b)] = [c[(a, b)], c[(-b_, a_)]]
ans = 1
used_cnt = double_zero_cnt
for key in d.keys():
    if d[key] == []:
        continue
    x, y = d[key]
    used_cnt += (x + y)
    mul = (pow(2, x, mod) + pow(2, y, mod) - 1) % mod
    ans *= mul
    ans %= mod
if a_zero_cnt > 0 and b_zero_cnt > 0:
    ans *= (pow(2, a_zero_cnt, mod) + pow(2, b_zero_cnt, mod) - 1)
    ans %= mod
    used_cnt += a_zero_cnt + b_zero_cnt
elif a_zero_cnt > 0:
    ans *= pow(2, a_zero_cnt, mod)
    ans %= mod
    used_cnt += a_zero_cnt
elif b_zero_cnt > 0:
    ans *= pow(2, b_zero_cnt, mod)
    ans %= mod
    used_cnt += b_zero_cnt
ans *= pow(2, n - (used_cnt), mod)
ans %= mod
ans -= 1
ans += double_zero_cnt
ans %= mod
print(ans)
N = int(input())
S = list(input())
K = int(input())
s = S[K-1]

for i in range(N):
    if S[i] == s:
        pass
    else:
        S[i] = '*'

print(''.join(S))


N = int(input())
S = input()
for i in range(N):



### FIXED CODE ###

N = int(input())
S = list(input())
K = int(input())
s = S[K-1]

for i in range(N):
    if S[i] == s:
        pass
    else:
        S[i] = '*'

print(''.join(S))