Harryxun/stf_run huggingface dataset:
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  ans = []

  for i in range(n-2):
    if x-i not in p:
      ans.append(-i)
      break
    elif x+i not in p:
      ans.append(i)
      break
    else:
      ans.append(-3)
  print(x+ans[0])

### FIXED CODE ###

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

if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  for j in range(0, int(n/2)+ 2):
    #print(j)
    if x-j not in p:
      print(x-j)
      break
    else:
      if x+j not in p:
        print(x+j)
        break
A,B,K=map(int,input().split())
num=list(range(A,B+1))
if len(num)%2!=0:
    ans_list=num[:K]+num[len(num)-K+1:]
elif len(num)%2==0:
    ans_list=num[:K]+num[len(num)-K:]
elif len(num)-K>0 or len(num)-K+1>0:
    ans_list=num[:K]
for i in range(len(ans_list)):
    print(ans_list[i])

### FIXED CODE ###

A,B,K=map(int,input().split())
if B-A+1-2*K>=0:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)
else:
    for i in range(A,B+1):
        print(i)
from sys import maxsize,stdin,stdout


def solve(ls, n, k):
	dp = [100001] * n
	dp[0] = 0
	if n == 1:
		return 0
	dp[1] = abs(ls[1] - ls[0])
	for i in range(2, n):
		j = 1
		while j <= k and i - j >= 0:
			dp[i] = (min((dp[i - j] + abs((ls[i - j]) - ls[i])), dp[i]))
			j += 1

	return f"{dp[n - 1]}"


n, k = map(int, stdin.readline().split())
ls = list(map(int, stdin.readline().split()))
stdout.write((solve(ls, n, k)))


### FIXED CODE ###

from sys import stdout, stdin, maxsize

n, k = map(int, stdin.readline().split())
ls = list(map(int, stdin.readline().split()))
dp = [maxsize] * (n + 1)
dp[1] = 0
if n == 1:
	print(0)
else:
	dp[2] = abs(ls[1] - ls[0])
	for i in range(3, n + 1):
		j = 1
		while j <= k and i - j >= 0:
			dp[i] = min(dp[i - j] + abs(ls[i - 1] - ls[i - 1 - j]), dp[i])
			j += 1
	print(dp[n])
N = int(input())
A = input().split()

pear = 0

for i in range(N, 1, -1):
  for j in range(i):
    if int(A[i]) >= (i - j):
      break
    if (i - j) == (int(A[i]) + int(A[j])):
      pear += 1
      
print(pear)
  

### FIXED CODE ###

N = int(input())
A = input().split()

pear = 0

i_result = {}
j_result = {}

for i in range(N):
  result = str(i + int(A[i]))
  if result in i_result:
    i_result[result] += 1
  else:
    i_result[result] = 1

for j in range(N):
  result = str(j - int(A[j]))
  if result in j_result:
    j_result[result] += 1
  else:
    j_result[result] = 1

for k in i_result.keys():
  if k in j_result:
    pear += (i_result[k] * j_result[k])
      
      
print(pear)
n = int(input())
a = []
b = []

for i in range(n):
    t = int(input())
    a.append(t)
    b.append(t)

b.sort()
m = 0
l = n+1

for i in range(n):
    m = 0
    l = n+1
    if a[i] != b[-1]:
        print(b[-1])
        continue
    while a[i] != b[(m+l)//2]:
        if a[i] < b[(m+l)//2]:
            l //= 2
        else:
            m = i
    tmp = b[(m+l)//2]
    b[(m+l)//2] = 0
    print(max(b))
    b[(m+l)//2] = tmp

### FIXED CODE ###

n = int(input())
a = []
b = []

for i in range(n):
    t = int(input())
    a.append(t)
    b.append(t)

b.sort()

for i in range(n):
    if a[i] != b[-1]:
        print(b[-1])
        continue
    else:
        print(b[-2])
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
x.sort()

if n>=m:
    print(0)
    import sys
    sys.quit()
l=[]
ans=x[-1]-x[0]
for i in range(m-1):
    l.append(abs(x[i]-x[i+1]))
l.sort()
l.reverse()
for i in range(n-1):
    ans-=l[i]
if ans>=0:
    print(ans)
else:
    print(0)

### FIXED CODE ###

n,m=map(int,input().split())
x=[int(i) for i in input().split()]
x.sort()

if n>=m:
    print(0)
    import sys
    sys.exit()
l=[]
ans=x[-1]-x[0]
for i in range(m-1):
    l.append(abs(x[i]-x[i+1]))
l.sort()
l.reverse()
for i in range(n-1):
    ans-=l[i]
if ans>=0:
    print(ans)
else:
    print(0)
d = 1000000007

def pow_rem(x, n):
    if n == 0:
        return x ** n % d
    if n % 2 == 0:
        return pow_rem(x, n // 2) ** 2 % d
    else:
        return ((pow_rem(x , n // 2) ** 2) * x) % d

def solve():
    m, n = map(int, input().split())
    print(pow_rem(m, n)

solve()

### FIXED CODE ###

d = 1000000007

def pow_rem(x, n):
    if n == 0:
        return x ** n % d
    if n % 2 == 0:
        return pow_rem(x, n // 2) ** 2 % d
    else:
        return ((pow_rem(x , n // 2) ** 2) * x) % d

def solve():
    m, n = map(int, input().split())
    print(pow_rem(m, n))

solve()
c = list(map(int,input().split()))
a = reduce(lambda x , y: x * y),c)
if a%4 == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a = int(input().replace(' ' ,''))
if a%4 == 0:
    print("YES")
else:
    print("NO")
N, A, B = map(int, input().split())
l = ""
cnt = 0
n1 = "b" * A
n2 = "r" * B
for i in range(N + 2):
    l += n1 + n2
   
for j in l[0 : N]:
    if j == "b":
        cnt += 1
          
print(cnt)


### FIXED CODE ###

n, a, b = map(int,input().split())
if a == 0 and b == 0:
    print(0)
if a != 0 or b != 0:
         
    kumi = n // (a + b)
    nokori = n % (a + b)
    if nokori == 0:
        print(a * kumi)
    elif nokori >= 1 and nokori < a:
        print(a * kumi + nokori)
    elif nokori >= a:
        print(a * kumi + a)
s=input()
t=input()

count=0
for i in range(s):
  if s[i]!=t[i]:
    count+=1

print(count)

### FIXED CODE ###

s=input()
t=input()

c=0
for i in range(len(s)):
    if s[i]!=t[i]:
        c+=1
print(c)
N, A, B = map(int, input().split())
cnt = 0
for i in range(1, N + 1):
  if A <= sum(list(str(i))) <= B:
    cnt += 1
print(cnt)

### FIXED CODE ###

N, A, B = map(int, input().split())
ans = 0
for i in range(1, N + 1):
  if A <= sum(map(int, list(str(i)))) <= B:
    ans += i
print(ans)
x=list(map(int,input().split())),int(input());print(sum(a)+max(a)*((2**x)-1)

### FIXED CODE ###

a,x=list(map(int,input().split())),int(input());print(sum(a)+max(a)*((2**x)-1))
N,M,*L = map(int, open('0').read().split())
dic = [[] for i in range(N+1)]
for a,b,c in zip(*[iter(L)]*3):
  dic[a].append(b)

ok = [False]*(N+1)
ok[1] = True
q = [1]
while q:
  p = q.pop()
  for v in dic[p]:
    if not ok[v]:
      ok[v] = True
      q.append(v)
cnt = 0
dist = [-10**20]*(N+1)
dist[1] = 0
while True:
  flag = True
  for a,b,c in zip(*[iter(L)]*3):
    if ok[a]&ok[b] and ok[a]!=-10**20 and dist[b]<dist[a]+c:
      flag = False
      dist[b] = dist[a]+c
  if flag:
    print(dist[N])
    break
  cnt += 1
  if cnt>N:
    print('inf')
    break

### FIXED CODE ###

from collections import defaultdict
N, M, *L = map(int, open(0).read().split())
dic = defaultdict(list)
rdic = defaultdict(list)
nin = [0]*N
Els = []
for a,b,c in zip(*[iter(L)]*3):
  dic[a-1] += [b-1]
  rdic[b-1] += [a-1]
  nin[b-1] += 1
  Els += [(a-1,b-1,-c)]

To = [False]*N
From = [False]*N
q = [0]
To[0] = True
while q:
  p = q.pop()
  for e in dic[p]:
    if To[e]==False:
      To[e] = True
      q += [e]
q = [N-1]
From[N-1] = True
while q:
  p = q.pop()
  for e in rdic[p]:
    if From[e]==False:
      From[e] = True
      q += [e]

ok = [False]*N
for i  in range(N):
  ok[i] = To[i]&From[i]

cnt = 0
dist = [float('inf')]*N
dist[0] = 0
cnt = 0
flag = False
while True:
  update = True
  for a,b,c in Els:
    if not(ok[a] and ok[b]):
      continue
    if dist[a]!=float('inf') and dist[b]>dist[a]+c:
      dist[b] = dist[a]+c
      update = False
  if update:
    break
  cnt += 1
  if cnt>2*N:
    flag = True
    break

if flag:
  print('inf')
elif dist[N-1]==float('inf'):
  print('inf')
else:
  print(-dist[N-1])
n,m,k=map(int,input().split())
fr=[0 for _ in range(n)]
bl=[0 for _ in range(n)]
frl=[[] for i in range(n)]
bll=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    fr[a-1]=fr[a-1]+1
    fr[b-1]=fr[b-1]+1
    frl[a-1].append(b)
    frl[b-1].append(a)

treelist=[]
hitobito=set()

def saiki(c):
    global treelist
    global hitobito
    global frl
    global bll
    global tmpset

    for tsugi in frl[c-1]:
        if not tsugi in hitobito:
            hitobito.add(tsugi)
            tmpset.add(tsugi)
            saiki(tsugi)

for i in range(n):
    tmpset=set()
    saiki(i+1)
    if not tmpset == set():
        treelist.append(tmpset)



for i in range(k):
    a,b=map(int,input().split())
    bl[a-1]=bl[a-1]+1
    bl[b-1]=bl[b-1]+1
    bll[a-1].append(b)
    bll[b-1].append(a)


output=[]
for i in range(n):
    for tree in treelist:
        if i+1 in tree:
            tmpsum=0
            for aaa in frl[i]:
                if aaa in tree:
                    tmpsum+=1
            for bbb in bll[i]:
                if bbb in tree:
                    tmpsum+=1 
            output.extend([str(len(tree)-tmpsum-1)," "])

print("".join(output))    




### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

n,m,k=map(int,input().split())
fr=[0 for _ in range(n)]
frl=[[] for i in range(n)]
frlist=[]
for i in range(m):
    a,b=map(int,input().split())
    frl[a-1].append(b)
    frl[b-1].append(a)
    frlist.append([a,b])

treelist=[]
hitobito=set()

def saiki(c,tmpi):
    global hitobito
    global tmpset
    global trbl
    
    if frl[c-1] == []:
        hitobito.add(c)
        tmpset.add(c)
        trbl[c-1]=tmpi
    
    for tsugi in frl[c-1]:
        if not tsugi in hitobito:
            hitobito.add(tsugi)
            tmpset.add(tsugi)
            trbl[tsugi-1]=tmpi
            saiki(tsugi,tmpi)

index=0
trbl=[None for _ in range(n)]
for i in range(n):
    tmpset=set()
    saiki(i+1,index)
    if not tmpset == set():
        treelist.append(tmpset)
        index+=1

bl=[0 for _ in range(n)]
bll=[[] for i in range(n)]
bllist=[]
for i in range(k):
    a,b=map(int,input().split())
    bll[a-1].append(b)
    bll[b-1].append(a)
    bllist.append([a,b])

for fre in frlist:
    if trbl[fre[0]-1] == trbl[fre[1]-1]:
        fr[fre[0]-1]=fr[fre[0]-1]+1
        fr[fre[1]-1]=fr[fre[1]-1]+1

for blo in bllist:
    if trbl[blo[0]-1] == trbl[blo[1]-1]:
        bl[blo[0]-1]=bl[blo[0]-1]+1
        bl[blo[1]-1]=bl[blo[1]-1]+1

output=[]
for i in range(n):
    tmpsum=fr[i]+bl[i]
    output.extend([str(len(treelist[trbl[i]])-tmpsum-1)," "])

print("".join(output))
N=int(input())
A=list(map(int,input().split()))
cnt=0
while True:
  if A%2==0:
    cnt+=1
  else:
    break
print(cnt)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
cnt=0

while all(i%2==0 for i in A):
  A=[i//2 for i in A]
  cnt+=1
print(cnt)
import sys
import heapq
from typing import Callable, List, NoReturn, Set


def dijkstra(n, path) -> List[int]:
    total_cost: List[int] = [10**5] * (n + 1)
    total_cost[1] = 0

    not_checked: Set[int] = set(range(1, n + 1))
    checked: Set[int] = set()
    cur_node: int = 1
    h: List = []

    while not_checked:
        checked.add(cur_node)
        not_checked -= {cur_node}

        for next_node in path[cur_node]:
            if next_node in not_checked:
                heapq.heappush(h, (total_cost[cur_node] + 1, next_node))

        if not_checked:
            cost, next_node = heapq.heappop(h)  # type: int, int

            while next_node in checked:
                cost, next_node = heapq.heappop(h)

            cur_node = next_node
            total_cost[cur_node] = cost

    return total_cost


def main() -> NoReturn:
    readline: Callable[[], str] = sys.stdin.readline

    n, m = map(int, readline().rstrip().split())  # type: int, int
    path: List[List[int]] = []
    for _ in range(n + 1):
        path.append([])
    for _ in range(n):
        a, b = map(int, readline().rstrip().split())  # type: int, int
        (path[a]).append(b)
        (path[b]).append(a)

    print("Yes")
    total_costs: List[int] = dijkstra(n, path)
    for i in range(2, n + 1):
        print(total_costs[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import heapq
from typing import Callable, List, NoReturn, Set


def dijkstra(n, path) -> List[int]:
    total_cost: List[int] = [10**5] * (n + 1)
    total_cost[1] = 0

    pointers: List[int] = [-1] * (n + 1)
    pointers[1] = 0

    not_checked: Set[int] = set(range(1, n + 1))
    checked: Set[int] = set()
    cur_node: int = 1
    h: List = []

    while not_checked:
        checked.add(cur_node)
        not_checked -= {cur_node}

        for next_node in path[cur_node]:
            if next_node in not_checked:
                heapq.heappush(h, (total_cost[cur_node] + 1, next_node, cur_node))

        if not_checked:
            cost, next_node, prev_node = heapq.heappop(h)  # type: int, int, int

            while next_node in checked:
                cost, next_node, prev_node = heapq.heappop(h)

            cur_node = next_node
            total_cost[cur_node] = cost
            pointers[cur_node] = prev_node

    return pointers


def main() -> NoReturn:
    readline: Callable[[], str] = sys.stdin.readline

    n, m = map(int, readline().rstrip().split())  # type: int, int
    path: List[List[int]] = []
    for _ in range(n + 1):
        path.append([])
    for _ in range(m):
        a, b = map(int, readline().rstrip().split())  # type: int, int
        (path[a]).append(b)
        (path[b]).append(a)

    print("Yes")
    pointers: List[int] = dijkstra(n, path)
    for i in range(2, n + 1):
        print(pointers[i])


if __name__ == '__main__':
    main()
a = int(input())
b = 100
c = 0
while true:
  b += int(b / 100)
  c += 1
  if b >= a:
    print(c)
    exit()

### FIXED CODE ###

a = int(input())
b = 100
c = 0
while True:
  b += int(b / 100)
  c += 1
  if b >= a:
    print(c)
    exit()
N=<999

N = input()

if N[-1]= 2or 4or 5 or 7 or 9:
  print('hon')
  
elif N[-1]==0or 1or 6or 8:
  print('pon')
  
else:
  print('bon')
  
  

### FIXED CODE ###

N = input()
 
if N[-1]=='2' or N[-1]=='4' or N[-1]=='5' or N[-1]=='7' or N[-1]=='9':
    print('hon')
     
elif N[-1]=='0' or N[-1]=='1' or N[-1]=='6' or N[-1]=='8':
    print('pon')
     
else:
    print('bon')
import numpy as np
L,R = map(int,input().split())
ans = L*(L+1)%2019

np1 = np.array(range(L,R))
np2 = np.multiply.outer(np1,np1)
np3 = np2%2019
np3[0,0] = 2019
np3[R-L-1,R-L-1]=2019
print(np.amin(np3))

### FIXED CODE ###

L,R = map(int,input().split())
ans = (L*(L+1))%2019
if R-L >= 2019:
    print(0)
    exit()
else:
    for i in range(L,R):
        for j in range(L+1,R+1):
            if ans > (i*j)%2019:
                ans = (i*j)%2019
print(ans)
N, Q = map(int, input().split())
S = input()

cumulatives = [0] * (N + 1)

for i in range(N):
  # 右隣にCが来るAの数を数える
  if S[i:i + 2] == 'AC':
    cumulatives[i + 1] = cumulatives[i] + 1
  else:
    cumulatives[i + 1] = cumulatives[i]

for i in range(Q):  
  l, r = map(lambda x: int(x) - 1, input().split())  # index 合わせる
  # 右隣の文字がCでない場合は条件を満たさないので右端を1左にずらす（開区間と考える）
  print(cumulatives[r] - cumulatives[l])　　　　　　　　　　　　　　　　　　

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

cumulatives = [0] * (N + 1)

for i in range(N):
  if i == 0:
    cumulatives[1] = 0
  elif S[i - 1] == 'A' and S[i] == 'C':
    cumulatives[i + 1] = cumulatives[i] + 1
  else:
    cumulatives[i + 1] = cumulatives[i]
        
for _ in range(Q):
  l, r = map(lambda x: int(x) - 1, input().split())
  if l > 0 and S[l - 1] == 'A' and S[l] == 'C':
    # 右も閉区間なので+1
    print(cumulatives[r + 1] - cumulatives[l] - 1)
  else:
    print(cumulatives[r + 1] - cumulatives[l])
N,M,X=map(int,input().split())
ca=[list(map(int,input().split())) for i in range(N)]
ans=float('inf')
for i in range(1,2**N):
  money=0
  rikaido=[0]*M
  for j in range(M):
    if i>>j&1:
      money+=ca[j][0]
      for k in range(1,M+1):
        rikaido[k-1]+=ca[j][k]
    for l in range(M):
      if all(rikaido[l]>=X for l in range(M)):
        ans=min(ans,money)

if ans==float('inf'):
  print(-1)
else:
  print(ans)

### FIXED CODE ###

S=input()
T=input()
count=1
for i in range(len(S)):
  if S[i]==T[i]:
    count=1
  else:
    count=0
    break
    
if count==1:
  if (len(S)+1)==len(T):
    print('Yes')
  else:
    print('No')
else:
  print('No')
S_A=list(input())
S_B=list(input())
S_C=list(input())

S_A=reversed(S_A)
S_B=reversed(S_B)
S_C=reversed(S_C)

turn='a'

while S_A!=[] and S_B!=[] and S_C!=[]:
  if turn=='a':
    turn=S_A.pop()
  elif turn=='b':
    turn=S_B.pop()
  else:
    turn=S_C.pop()

if S_A==[]:
  print('A')
elif S_B==[]:
  print('B')
else:
  print('C')

### FIXED CODE ###

S_A=list(input())
S_B=list(input())
S_C=list(input())

S_A=S_A[::-1]
S_B=S_B[::-1]
S_C=S_C[::-1]

turn='a'

while True:
  if turn=='a':
    if S_A==[]:
      print('A')
      break
    else:
      turn=S_A.pop()
  elif turn=='b':
    if S_B==[]:
      print('B')
      break
    else:
      turn=S_B.pop()
  else:
    if S_C==[]:
      print('C')
      break
    else:
      turn=S_C.pop()
A = "abcdefghijklmnopqrstu"
c = input()

print(A[A.index(c)+1])


### FIXED CODE ###

A = "abcdefghijklmnopqrstuvwxyz"
c = input()

print(A[A.index(c)+1])
n = int(input())
a = list(map(int,input().split()))

f = 0
cnt = 0
if a[0] < a[1]:
    f = 1
elif a[0] > a[1]:
    f = 2
tmp = a[1]

for i in range(2,n):
    if tmp < a[i]:
        if f == 2:
            cnt += 1
            f = 0
        elif f == 0:
            f = 1
    elif tmp > a[i]:
        if f == 1:
            cnt += 1
            f = 0
        elif f == 0:
            f = 2
    else:
        continue
    tmp = a[i]
cnt += 1

print(cnt)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))

if n <= 2:
    print(1)
    exit()

f = 0
cnt = 0
if a[0] < a[1]:
    f = 1
elif a[0] > a[1]:
    f = 2
tmp = a[1]

for i in range(2,n):
    if tmp < a[i]:
        if f == 2:
            cnt += 1
            f = 0
        elif f == 0:
            f = 1
    elif tmp > a[i]:
        if f == 1:
            cnt += 1
            f = 0
        elif f == 0:
            f = 2
    tmp = a[i]
cnt += 1

print(cnt)
from collections import deque
while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    *S, = map(int, input().split())
    *D, = map(int, input().split())

    deq = deque(S)
    D.sort()
    def dfs(r, idx, prev):
        if idx == m:
            return 0
        if r == n:
            s = 0
            while idx < m:
                s += D[idx] - prev
                idx += 1
            return s
        res = 10**18
        for i in range(n - r):
            v = deq.popleft()
            nxt = prev + v
            s = 0; j = idx
            while j < m and D[j] <= nxt:
                s += min(nxt - D[j], D[j] - prev); j += 1
            res = min(res, s + dfs(r+1, j, nxt))
            deq.append(v)
        return res
    print(dfs(0, 0, 0))

### FIXED CODE ###

from collections import deque
while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    *S, = map(int, input().split())
    D = sorted(map(int, input().split()))

    SA = sum(S)
    rest = sum(d-SA for d in D if SA <= d)

    memo = {2**n-1: rest}
    def dfs(state, su, idx):
        if state in memo:
            return memo[state]
        res = 10**18
        for i in range(n):
            if (state >> i) & 1 == 0:
                s = 0; j = idx
                nxt = su + S[i]
                while j < m and D[j] <= nxt:
                    s += min(nxt - D[j], D[j] - su); j += 1
                res = min(res, s + dfs(state | (1 << i), su + S[i], j))
        memo[state] = res
        return res
    print(dfs(0, 0, 0))
a,b,x = map(int,input().split())

if a <= x <= a+b:
:(tnirp )"SEY"
  :esle
    )"ON@"(tnir

### FIXED CODE ###

a,b,x=map(int,input().split())

if a<=x<=a+b:
  print("YES")
else:
  print("NO")
N = int(input())
S = [str(input()) for i in range(N)]

S = sorted(S)
count = 0
first = 0
removecount = 0

for i in range(N):
    j = 0
    while first + count + 1 < len(S) :
        if S[first]==S[first+1+j]:
            S[first+1+j] = "nullsad"
            count+=1
            j += 1
            print(S)
        else:
            first += count + 1
            removecount += count
            count = 0
            print(S)
            break

for i in range(removecount + count):
    S.remove("nullsad")

print(len(S))


### FIXED CODE ###

N = int(input())
S = [str(input()) for i in range(N)]

S = sorted(S)
count = 0
first = 0
removecount = 0

for i in range(N):
    j = 0
    while first + count + 1 < len(S) :
        if S[first]==S[first+1+j]:
            S[first+1+j] = "null"
            count+=1
            j += 1
        else:
            first += count + 1
            removecount += count
            count = 0
            break

print(len(S)-S.count("null"))
N = int(input())
K = int(input())
print(N-K)

### FIXED CODE ###

N,K = map(int,input().split())
if K == 1:
    print(0)
else:
    print(N-K)
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
from sys import flags
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]

for i in range(d):
    for j in range(n):
        if i%a[j]==0:
            x+=1

print(x)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]

for i in range(d):
    for j in range(n):
        if i%a[j]==0:
            x+=1

print(x)

### FIXED CODE ###

import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
d,x=map(int,input().split())
a=[int(input()) for i in range(n)]

for i in range(d):
    for j in range(n):
        if i%a[j]==0:
            x+=1

print(x)
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    mod = 10**9 + 7
    # A = []
    # B = []
    C = []
    for i in range(n):
        a,b = map(int, input().split())
        C.append(a/b)
    import numpy as np
    # A = np.array(A)
    # B = np.array(B)
    C = np.array(C)
    C_p = C[C>=0]
    C_n = C[C<0]
    from collections import Counter as cc
    C_p,C_n = cc(C_p),cc(C_n)
    num = 0
    count= 0
    re = 1
    for c in C_p:
        if -1/c in C_n:
            num = C_n[-1/c] + C_p[c]
            count += num
            re *= (2**C_n[-1/c] + 2**C_p[c] -1)%mod
    ans = pow(2,n-count,mod)*re%mod -1
    print(ans)



if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    from collections import Counter as cc
    from fractions import gcd
    n = int(input())
    mod = 10**9 + 7
    C_p,C_n = cc(),cc()
    count= 0
    count_zero_a = count_zero_b = 0
    ans = 1
    for i in range(n):
        a,b = map(int, input().split())
        if a == 0 and b== 0:
            count += 1
        else:
            gcd_ab = gcd(a,b)
            a //= gcd_ab
            b //= gcd_ab
            if b == 0:
                count_zero_b += 1
            elif a == 0: 
                count_zero_a += 1
            else:
                if a/b>0:
                    C_p[a,b] += 1
                else:
                    C_n[a,b] += 1
    count_zero = count
    ans *= (2**count_zero_a + 2**count_zero_b -1)%mod
    count += count_zero_a + count_zero_b    
    for a,b in C_p:
        if (-b,a) in C_n:
            count += C_n[-b,a] + C_p[a,b]
            ans *= (2**C_n[-b,a] + 2**C_p[a,b] -1)%mod
    ans *= pow(2,n-count,mod)%mod
    ans = (ans +count_zero -1) % mod
    print(ans)


if __name__ == '__main__':
    main()