Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N,K = map(int,input().split())
MOD = 10**9+7

m = 1
a,b = [],[]
while m*m <= N:
    a.append(m)
    b.append(N//m)
    m += 1
if a[-1] == b[-1]:
    b.pop()
a += b[::-1]
w = [b-a for a,b in zip([0]+a, a)]

L = len(a)
dp = [1]*L
for _ in range(K-1):
    dp2 = [0]*L
    c = 0
    for i,v in enumerate(w):
        c += dp[i] * v
        dp2[L-1-i] += c
        dp2[L-1-i] %= MOD
    dp = dp2
ans = sum(a*b for a,b in zip(w,dp))
print(ans%MOD)

### FIXED CODE ###

N,K = map(int,input().split())
MOD = 10**9+7

m = 1
a,b = [],[]
while m*m <= N:
    a.append(m)
    b.append(N//m)
    m += 1
if a[-1] == b[-1]:
    b.pop()
a += b[::-1]
w = [b-a for a,b in zip([0]+a, a)]

L = len(a)
dp = [1]*L
for _ in range(K-1):
    dp2 = [0]*L
    c = 0
    for i,v in enumerate(w):
        c += dp[i] * v
        dp2[L-1-i] += c
        dp2[L-1-i] %= MOD
    dp = dp2
ans = sum(a*b for a,b in zip(w,dp))
print(ans%MOD)
### BUGGY CODE ###

n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
count = 0
now = 0
i= 0

dp = [0]*(n+1)
if 1 in base:
  dp[1] = 0
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not(i in base):
    dp[i] = dp[i-1] + dp[i-2]
  
  
print(int(dp[n]%1000000007))

### FIXED CODE ###

n,m = map(int,input().split())
base = [int(input()) for i in range(m)]
i= 0
j = 0

dp = [0]*(n+1)
if m == 0:
  base = [n+1]

if 1 == base[j]:
  dp[1] = 0
  if j < m-1:
    j = j + 1
else:
  dp[1] = 1

dp[0] = 1

for i in range(2,n+1):
  if not (i == base[j]):
    dp[i] = dp[i-1] + dp[i-2]
  elif i == base[j]:
    if j < m-1:
      j = j + 1
  
  
print(int(dp[n]%1000000007))
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A = list(int(input()) for _ in range(Q))

a = list(set(A))
ans = []
for i in range(N):
  if i + 1 in a:
    if Q - A.count(i + 1) < K:
      ans.append("Yes")
    else:
      ans.append("No")
  elif Q < K:
    ans.append("Yes")
  else:
    ans.append("No")

for x in ans:
  print(x)

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = list(int(input()) for _ in range(Q))

score = [0] * N
for i in range(Q):
  score[A[i] - 1] += 1
 
ans = []
for j in range(N):
  if K - Q + score[j] <= 0:
    ans.append("No")
  else:
    ans.append("Yes")
 
for a in ans:
  print(a)
### BUGGY CODE ###

import sys
imput=sys.stdin.readline
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
l.sort()

dp=[[float('inf')]*(n+1) for i in range(m+1)]
for i in range(m+1):
    dp[i][0]=0;dp[i][1]=0
for i in range(1,m+1):
    dp[i]=dp[i-1]
    for j in range(l[i-1][0],l[i-1][1]+1):
        dp[i][j]=min(dp[i][j],dp[i-1][l[i-1][0]]+l[i-1][2])
if dp[-1][-1]==float('inf'):
    print(-1)
else:
    print(dp[-1][-1])


### FIXED CODE ###

import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d



n,m=map(int,input().split())#n:頂点数　w:辺の数

edge = [[] for i in range(n)] #edge[i] : iから出る道の[重み,行先]の配列

l=[list(map(int,input().split())) for i in range(m)]
for i in range(m):
    x,y,z =l[i][0],l[i][1],l[i][2]
    x-=1
    y-=1
    edge[x].append([z,y])
    edge[y].append([z,x])
for i in range(1,n):
    edge[i].append([0,i-1])
#print(edge)
#print(dijkstra_heap(0))
a=dijkstra_heap(0)

if a[-1]==float('inf'):
    print(-1)
else:
    print(a[-1])
### BUGGY CODE ###

from collections import deque
n = int(input())
Ps = list(map(lambda x: int(x)-1, input().split()))
cost = [min(min(i, n-1-i), min(j, n-1-j)) for i in range(n) for j in range(n)]
DIRC = [(-1, 0), (0, 1), (1, 0), (0, -1)]
exist = [1]*(n**2)


def to_idx(p):
    i, j = divmod(p, n)
    return i, j


def to_v(i, j):
    return i*n+j


def bfs(init_v):
    next_v = deque([to_idx(init_v)])
    exist[init_v] = 0
    while next_v:
        i, j = next_v.popleft()
        for di, dj in DIRC:
            x, y = i+di, j+dj
            if x < 0 or y < 0 or n <= x or n <= y:
                continue
            c = cost[to_v(i, j)]+exist[to_v(i, j)]
            if cost[to_v(x, y)] <= c:
                continue
            cost[to_v(x, y)] = c
            next_v.append((x, y))


ans = 0
for p in Ps:
    ans += cost[p]
    bfs(p)
print(ans)

### FIXED CODE ###

from collections import deque
n = int(input())
Ps = list(map(lambda x: int(x)-1, input().split()))
cost = [min(i, n-1-i, j, n-1-j) for i in range(n) for j in range(n)]
exist = [1]*(n**2)


def to_idx(p):
    return divmod(p, n)


def to_v(i, j):
    return i*n+j


def bfs(init_v):
    next_v = deque([init_v])
    exist[init_v] = 0
    while next_v:
        v = next_v.popleft()
        i, j = to_idx(v)
        if 0 < i:
            v2 = v-n
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if i < n-1:
            v2 = v+n
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if 0 < j:
            v2 = v-1
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

        if j < n-1:
            v2 = v+1
            if cost[v2] > cost[v]+exist[v]:
                cost[v2] = cost[v]+exist[v]
                next_v.append(v2)

ans = 0
for p in Ps:
    ans += cost[p]
    bfs(p)
print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())
qlst = []
for i in range(Q):
    qlst.append(input().split())
ans = S
rtmp = 0
for i in range(Q):
    if qlst[i][0] == '1':
        rtmp += 1
    else:
        if rtmp % 2 == 0:
            if qlst[i][1] == '1':
                ans = qlst[i][2] + ans
            else:
                ans = ans + qlst[i][2]
        else:
            if qlst[i][1] == '2':
                ans = qlst[i][2] + ans
            else:
                ans = ans + qlst[i][2]

if rtmp % 2 != 0:
    print(ans[::-1])
else:
    print(ans)

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())
ans = deque(S)
revcnt = 0
for i in range(Q):
    data = list(input().split())
    if data[0] == '1':
        revcnt += 1
        continue

    if data[1] == '1':
        if revcnt % 2 == 0:
            ans.appendleft(data[2])
        else:
            ans.append(data[2])
    else:
        if revcnt % 2 == 0:
            ans.append(data[2])
        else:
            ans.appendleft(data[2])

if revcnt % 2 != 0:
    print(''.join(reversed(list(ans))))
else:
    print(''.join(list(ans)))
### BUGGY CODE ###

import heapq

he,w,k = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
l = [list(input()) for i in range(he)]

sx -= 1
sy -= 1
gx -= 1
gy -= 1
h = []
d = [[float("INF")]*w for i in range(he)]

d[sx][sy] = 0
heapq.heappush(h,(0,sx,sy))
while h:
    dis,bx,by = heapq.heappop(h)
    if bx == gx and by == gy:
        continue
    for i in range(1,k+1):
        if 0 <= bx+i < he and l[bx+i][by] != "@":
            if d[bx+i][by] > dis+1:
                d[bx+i][by] = dis+1
                heapq.heappush(h,(dis+1,bx+i,by))
        else:
            break
    for i in range(1,k+1):
        if 0 <= bx-i < he and l[bx-i][by] != "@":
            if d[bx-i][by] > dis+1:
                d[bx-i][by] = dis+1
                heapq.heappush(h,(dis+1,bx-i,by))
        else:
            break
    for i in range(1,k+1):
        if 0 <= by+i < w and l[bx][by+i] != "@":
            if d[bx][by+i] > dis+1:
                d[bx][by+i] = dis+1
                heapq.heappush(h,(dis+1,bx,by+i))
        else:
            break
    for i in range(1,k+1):
        if 0 <= by-i < w and l[bx][by-i] != "@":
            if d[bx][by-i] > dis+1:
                d[bx][by-i] = dis+1
                heapq.heappush(h,(dis+1,bx,by-i))
        else:
            break

if d[gx][gy] == float("INF"):
    print(-1)
else:
    print(d[gx][gy])

### FIXED CODE ###

from collections import deque

he,w,k = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
l = [list(input()) for i in range(he)]

sx -= 1
sy -= 1
gx -= 1
gy -= 1
q = deque([])
d = [[float("INF")]*w for i in range(he)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
d[sx][sy] = 0
q.append((0,sx,sy))
while q:
    dis,bx,by = q.popleft()
    if bx == gx and by == gy:
        continue
    for i in range(4):
        for j in range(1,k+1):
            nx = bx+dx[i]*j
            ny = by+dy[i]*j
            if 0 > nx or 0 > ny or nx >= he  or ny >= w:
                break
            if l[nx][ny] == "@":
                break
            if d[nx][ny] <= dis:
                break
            if d[nx][ny] > dis+1:
                d[nx][ny] = dis+1
                q.append((dis+1,nx,ny))

if d[gx][gy] == float("INF"):
    print(-1)
else:
    print(d[gx][gy])
### BUGGY CODE ###

from fractions import *

K = int(input())

ans = 0
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            if i == j and j == k and k == i:
                ans += i
            elif i != j and j != k and k != i:
                ans += gcd(gcd(i, j), k) * 6
            else:
                ans += gcd(gcd(i, j), k) * 3

print(ans)

### FIXED CODE ###

from math import *

K = int(input())

ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        tmp = gcd(i, j)
        for k in range(1, K+1):
            ans += gcd(tmp, k)

print(ans)
### BUGGY CODE ###

A,B,N=map(int,input().split())
result=0
for x in range(0,N+1):
	a=(A*x)//B-A*(x//B)
	if a>result:
		result=a
print(result)

### FIXED CODE ###

A,B,N=map(int,input().split())
if B!=1:
	p=(N+1)//B
	result=0
	if p!=0:
		for a in range(1,p+1):
			x=a*B-1
			s=(A*x)//B - A*(a-1)
			if result < s:
				result=s
	else:
		result=A*N//B -A*(N//B)
	print(result)
else:
	print(0)
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
p = "YES"

for i in range(n):
    for j in range(n-i-1):
        if l[i] == l[i+1+j]:
            p = "NO"
    
print(p)

### FIXED CODE ###

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

if len(l) != len(set(l)):
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

from collections import deque

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

c1 = deque(list(0 for i in range(N)))
c2 = deque()
c3 = deque()
c4 = deque()
c5 = deque()
c6 = deque()

counter = 0
def transfer(start, end, capacity):
    for i in range(capacity):
        if len(start) != 0:
            end.append(start.pop())
            
while len(c6) != N:
    counter += 1
    transfer(c5, c6, E)
    transfer(c4, c5, D)
    transfer(c3, c4, C)
    transfer(c2, c3, B)
    transfer(c1, c2, A)
print(counter)


### FIXED CODE ###

import math
from collections import deque

N = int(input())
X = deque()
for i in range(5):
        X.append(int(input()))
m = min(X)
print(math.ceil(N/m)+4)
### BUGGY CODE ###

_, Q = [int(s) for s in input().strip().split(' ')]
S = input().strip()

for i in range(Q):
    l, r = [int(s) for s in input().strip().split(' ')]

    cnt = 0
    s = S[l - 1:r]
    for j in range(len(s) - 1):
        t = s[j:j + 2]
        if t == 'AC':
            cnt += 1

    print(cnt)


### FIXED CODE ###

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

t = [0] * (N + 1)

for i in range(N):
    t[i + 1] = t[i] + (1 if S[i:i + 2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
### BUGGY CODE ###

import sys
from fractions import gcd
from itertools import combinations
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

K = int(read())
ans = 0

for a in range(1, K + 1):
    for b in range(1, K + 1):
        acc = gcd(a, b)
        for c in range(1, K + 1):
            acc_ = gcd(acc, c)
            ans += acc_
print(ans)

### FIXED CODE ###

import sys
#from fractions import gcd
from math import gcd
from itertools import combinations
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

K = int(read())
ans = 0

for a in range(1, K + 1):
    for b in range(1, K + 1):
        acc = gcd(a, b)
        for c in range(1, K + 1):
            acc_ = gcd(acc, c)
            ans += acc_
print(ans)
### BUGGY CODE ###

from math import factorial

N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7


# 2回表れている値とそのインデックスを取得
G = set()
for a in A:
    if a in G:
        C = a
    else:
        G.add(a)
C_indexes = [i for i, x in enumerate(A) if x == C]

# 二つのCの外側にそれぞれ何個ずつあるか
outside = C_indexes[0] + len(A) - C_indexes[1] - 1

X = factorial(N+1)
O = factorial(outside)

L = list(range(1, N+2))
M = [1] + list(range(1, outside+1))

l1 = 1
l2 = X
o1 = O
oc = 0
X %= MOD
O %= MOD

for k in range(1, len(A)+1):
    l1 *= k
    l2 //= L[-k]
    if k > outside + 1:
        Y = pow((l1 * l2) % MOD, MOD-2, MOD)
        print((X * Y) % MOD)
    else:
        oc += 1
        Y = pow(l1 * l2 % MOD, MOD - 2, MOD)
        Y2 = pow(l1//k * o1 % MOD, MOD - 2, MOD)
        print(((X * Y) % MOD - (O * Y2) % MOD))
        o1 //= M[-oc]



### FIXED CODE ###

from statistics import mode

N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

# 2回表れている値とそのインデックスを取得
C = mode(A)
C_indexes = [i for i, x in enumerate(A) if x == C]

# 二つのCの外側にそれぞれ何個ずつあるか
outside = C_indexes[0] + len(A) - C_indexes[1] - 1

# 階乗・逆元の値を保存
factorial = [1]
inverse = [1]
for i in range(1, N+2):
    factorial.append(factorial[-1]*i % MOD)
    inverse.append((pow(factorial[i], MOD-2, MOD)))

# combination計算
def nCr(n, r):
    if n<r or n==0 or r==0:
        return 0
    return factorial[n] * inverse[r] * inverse[n-r] % MOD


print(N)
for i in range(2, N+2):
    print(int(nCr(N+1, i) - nCr(outside, i-1)) % MOD)
### BUGGY CODE ###

import heapq 

N,M=map(int, input().split())
A=list(map(int, input().split()))
B = {}
C = {}
for i in range(M):
    B[i],C[i]=map(int, input().split())

high_scores = sorted(C.items(), key=lambda x:x[1], reverse=True)

heapq.heapify(A) 
for score in high_scores:
    num = B[score[0]]
    for i in range(num):
        min_num = heapq.heappop(A)
        heapq.heappush(A, max(min_num, score[1])) 

print(sum(A))

### FIXED CODE ###

N,M=map(int, input().split())
A=list(map(int, input().split()))
B = {}
C = {}
for i in range(M):
    B[i],C[i]=map(int, input().split())

high_scores = sorted(C.items(), key=lambda x:x[1], reverse=True)

sum_b = 0
for score in high_scores:
    sum_b += B[score[0]]
    if N < sum_b:
        A += [score[1]] *  (B[score[0]]-sum_b+N)
        break
    else:
        A += [score[1]] *  B[score[0]]

A.sort(reverse=True)
A = A[:N]

print(sum(A))
### BUGGY CODE ###

N=int(input())
P = list(map(int,input().split()))
ans=0
 
 
for i in range(N):
    if min(P[:i+1])==P[i]:
        ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
P = list(map(int,input().split()))
ans=0
m=P[0]
 
for i in range(N):
    if m >= P[i]:
        ans += 1
        m = P[i]

print(ans)
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]

INF = float('inf')

d = [[INF] * W for _ in range(H)]


def bfs(i, j):
    q = deque()
    q.append((i, j))
    d[i][j] = 0

    while len(q):
        x, y = q.popleft()
        for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            nx = x + dx
            ny = y + dy

            if (0 <= nx < H) and (0 <= ny < W) and d[nx][ny] > d[x][y] + 1:
                q.append((nx, ny))
                if grid[nx][ny] == '#':
                    d[nx][ny] = 0
                else:
                    d[nx][ny] = d[x][y] + 1


for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            bfs(i, j)
            break
    else:
        continue
    break

res = 0
for i in range(H):
    for j in range(W):
        res = max(res, d[i][j])

print(res)


### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]

# d = [[2001] * W for _ in range(H)]


def bfs(q):
    res_q = deque()
    while len(q):
        x, y = q.popleft()
        for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            nx = x + dx
            ny = y + dy

            if (0 <= nx < H) and (0 <= ny < W) and grid[nx][ny] != '#':
                res_q.append((nx, ny))
                grid[nx][ny] = '#'
    return res_q


q = deque()
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            q.append((i, j))

res = 0
while len(q):
    res += 1
    q = bfs(q)

print(res - 1)
### BUGGY CODE ###

import itertools
import collections


def resolve():
    N = int(input())
    s = [input() for _ in range(N)]
    ans = 0
    for tmp in itertools.combinations(s, 2):
        d1 = collections.defaultdict(int)
        d2 = collections.defaultdict(int)
        for ch in tmp[0]:
            d1[ch] += 1
        for ch in tmp[1]:
            d2[ch] += 1
        if d1 == d2:
            ans += 1
    print(ans)


resolve()


### FIXED CODE ###

def resolve():
    N = int(input())
    s = [input() for _ in range(N)]
    ans = 0
    chk = {}
    for tmp in s:
        d1 = "".join(sorted(list(tmp)))
        if d1 in chk.keys():
            ans += chk[d1]
            chk[d1] += 1
        else:
            chk[d1] = 1
    print(ans)


resolve()
### BUGGY CODE ###

import bisect

N=int(input())
L=list(map(int, input().split()))
L.sort()

ans=0

for i in range(N-2):
  for j in range(i+1,N-1):
    small = bisect.bisect_left(L, L[j]-L[i])
    large = bisect.bisect_left(L, L[j]+L[i])
    
    #print(i,j,L[i],L[j],"  ",L[j]-L[i],L[j]+L[i],small,large)
    ans += max(large-j-1,0)    
print(ans)

### FIXED CODE ###

import bisect

N=int(input())
L=list(map(int, input().split()))
L.sort()

ans=0
for i in range(N-2):
  for j in range(i+1,N-1):
    #small = bisect.bisect_left(L, L[j]-L[i])
    large = bisect.bisect_left(L, L[j]+L[i])    
    #print(i,j,L[i],L[j],"  ",L[j]-L[i],L[j]+L[i],small,large)
    ans += max(large-j-1,0)    

print(ans)
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
    wk = 0
    count = 0
    for j in range(0,i):
        if p[j] >= p[i]:
            wk += 1
        count += 1
    if wk == count:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
for i in range(n):
    if i == 0:
        ans = 1
        minp = p[i]
    elif minp >= p[i]:
        ans += 1
        minp = min(minp,p[i])
print(ans)
### BUGGY CODE ###

def D():
    s = input()
    sketa = len(s)
    ans = 0
    mods = [0]*2019
    mods[0] = 1
    for i in range(1,sketa+1):
        mod = int(s[-i:])%2019
        ans += mods[mod]
        mods[mod] += 1
    print(ans)
D()


### FIXED CODE ###

def D():
    s = input()
    mods = [0]*2019
    mods[0] = 1
    mod = 0
    for i, element in enumerate(s[::-1]):
        mod += int(element)*pow(10,i,2019)
        mods[mod%2019] += 1
    print(sum(map(lambda x:int(x*(x-1)/2), mods)))
D()
### BUGGY CODE ###

N = int(input())
divs = [0]*(N+1)
for i in range(1, N+1):
    for j in range(1, N//i + 1):
        divs[i*j] += 1

ans = 0
for i in range(N+1):
    ans += i*divs[i]

print(ans)




### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1, N+1):
    Ni = N // i
    ans += i*Ni*(Ni+1) // 2

print(ans)
### BUGGY CODE ###

N = int(input())
print(0, flush=True)
s0 = input()
if s0 == 'Vacant':
    exit()
l = 0
r = N-1

while r - l > 1:
    m = (l+r) // 2  # 中央値のクエリを送る
    print(m, flush=False)
    s = input()
    if s == 'Vacant':
        exit()
    if m & 2 == 1:  # r-lが奇数であることと同義
        if s != s0:  # 異性ならば
            l = m  # 前半部分に空席はないから下限をあげる
        else:  # 同性ならば
            r = m  # 前半部分に空席があるので上限を下げる
    else:  # r-lが偶数であることと同義
        if s != s0:  # 異性ならば
            r = m  #
        else:  # 同性ならば
            l = m
print(r, flush=True)
sr = input()


### FIXED CODE ###

# 円状に席が並んでいるので、空席を作ると男女の並びが不自然になるのは確か
# 男 空席 男 とやると一見空席が見つけられないような気がするが、それは円のどこかで同性同士が隣り合ってしまうので無理
# 空席の隣は必ず男と女である

N = int(input())
# Vacantがあるとそこで並びがずれる

# 0を基準とする
print(0, flush=True)  # 0番目の座席に対してリクエストを送る
s0 = input()
if s0 == "Vacant":
    exit()

l = 0  # ずれていない(ずれているかも)
r = N-1  # ずれている
while r - l > 1:
    m = (l+r) // 2  # 中央値のリクエストを送る
    print(m, flush=False)
    s = input()
    if s == 'Vacant':
        exit()
    if m % 2 == 1:
        if s != s0:
            l = m
        else:
            r = m
    else:
        if s != s0:
            r = m
        else:
            l = m
print(r, flush=True)
sr = input()
### BUGGY CODE ###

def main():
    S = input()
    div = pow(10, 9) + 7
    rem = [0 for _ in range(13)]
    rem[0] = 1
    for c in S:
        temp = [0 for _ in range(13)]
        if c != "?":
            for i in range(13):
                r = (i*10+int(c)) % 13
                temp[r] += rem[i] % div
        else:
            for i in range(13):
                for j in range(10):
                    r = (i*10+j) % 13
                    temp[r] += rem[i] % div
        rem = temp
    return rem[5] % div

if __name__ == '__main__':
    print(main())

### FIXED CODE ###

def main():
    S = input()
    div = pow(10, 9) + 7
    rem = [0 for _ in range(13)]
    rem[0] = 1
    for c in S:
        temp = [0 for _ in range(13)]
        if c != "?":
            for i in range(13):
                r = (i*10+int(c)) % 13
                temp[r] += rem[i] % div
        else:
            for i in range(13):
                for j in range(10):
                    r = (i*10+j) % 13
                    temp[r] += rem[i] % div
        rem = temp
    return rem[5] % div

if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

import numpy as np

n = int(input())
li = [np.full(n, -1, dtype=np.int) for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        li[i][x-1] = y

ans = 0
for i in range(2**n):
    s = 0
    t = [0]*n
    for j in range(n):
        if i>>j & 1:
            t[j]=1
    is_contradict = 0
    for j in range(n):
        if t[j]:
            for k in range(n):
                if li[j][k]==-1:
                    continue
                if li[j][k] != t[k]:
                    is_contradict = 1
    if not is_contradict:
        ans = max(ans, sum(t))

print(ans)

### FIXED CODE ###

n = int(input())
li = [[-1 for _ in range(n)] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        li[i][x-1] = y

ans = 0
for i in range(2**n):
    s = 0
    t = [0]*n
    for j in range(n):
        if i>>j & 1:
            t[j]=1
    is_contradict = 0
    for j in range(n):
        if t[j]:
            for k in range(n):
                if li[j][k]==-1:
                    continue
                if li[j][k] != t[k]:
                    is_contradict = 1
    if not is_contradict:
        ans = max(ans, sum(t))

print(ans)