Harryxun/stf_run huggingface dataset:
n, m = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
c = [0] * m
d = [0] * m
for j in range(m):
    c[j], d[j] = list(map(int, input().split()))

for i in range(n):
    distance = []
    minDistance = 10 ** 8 + 1
    checkPoint = 1
    for j in range(m):
        if j == 0:
            checkPoint = 1
        else:
            distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
            if minDistance > distance[j]:
                minDistance = distance[j]
                checkPoint = j + 1
    print(checkPoint)

### FIXED CODE ###

n, m = list(map(int, input().split()))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
c = [0] * m
d = [0] * m
for j in range(m):
    c[j], d[j] = list(map(int, input().split()))

for i in range(n):
    distance = []
    minDistance = 10 ** 16
    checkPoint = 1
    for j in range(m):
        distance.append(abs(a[i] - c[j]) + abs(b[i] - d[j]))
        if minDistance > distance[j]:
            minDistance = distance[j]
            checkPoint = j + 1
    print(checkPoint)
#最も上にいる親をたどる
# xは自分自身の番号を示す。
# r[x]は自分の親を示す。親がいない場合は-1を示す。
def root(x):
  # case parent
  if r[x] < 0:
    return x
  # case child
  else:
    return root(r[x])

#from operator import itemgetter

n, m = map(int, input().split())
road = [list(map(int,input().split())) for i in range(m)]
#root -1は上がいない、そのほかは親をもちその数字を表す。
r = [-1]*(n+1)

#print(g)

road = sorted(road, key=lambda x:(x[0], x[1]))
#print(r)

group_num = 1;

for i, city in enumerate(road):
  city_a = city[0]
  city_b = city[1]
  city_a_par = root(city_a)
  city_b_par = root(city_b)
  
  #print(r)
  #print("city_a", city_a, "city_b", city_b)
  
  # 親に子をつなげていく
  # cityに親がいない（自分が親である=-1可能性あるが問題ない）
  if r[city_a] == -1 and r[city_b] == -1:
    # city_bの親をcity_aにする
    r[city_b] = city_a
  # どちらか片方のみが子である
  elif r[city_a] == -1 or r[city_b] == -1:
    # aが子
    if r[city_a] > r[city_b]:
      r[city_b] = r[city_a]
    # bが子
    else:
      r[city_a] = r[city_b]
  # aもbも誰かの子である
  else:
    if city_a_par == city_b_par:
      pass
    else:
      r[city_b_par] = city_a
      
del r[0]
#print(group_num-1)
#print(r.count(-1))
#print(r)
print(group_num-1+r.count(-1)-1)

### FIXED CODE ###

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
    # ノードxのrootノードを見つける
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
    # 木の併合、入力は併合したい各ノード⇒(a,b)
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
    # ノードxが属する木のサイズを返す
        return -self.parents[self.find(x)]

    def same(self, x, y):
    # 入力ノード(x,y)が同じグループに属するかを返す
        return self.find(x) == self.find(y)

    def members(self, x):
    #ノードxが属するメンバーをリスト形式で返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
    #親全てをリスト形式で返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
    #グループ数の合計を返す
        return len(self.roots())

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n,m=map(int,input().split())
u=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    u.unite(a,b)
ans=u.roots()
print(len(ans)-1)
N = int(iuput())
W = list(map(int,input.split()))
s = sum(W)
ans = 0
for w in W:
  if s - ans <= s - ans + w:
    break
  else:
    ans += w
print(s - ans)

### FIXED CODE ###

N = int(input())
W = list(map(int,input().split()))
s = sum(W)
ans = 0
for w in W:
  if abs(s - 2*ans) <= abs(s - 2*(ans + w)):
    break
  else:
    ans += w
print(abs(2*ans-s))
n,d=int(input()),int(input())
c = 0
d *= d
for i in range(n):
  a,b=int(input()),int(input())
  if(a**2+b**2==d):
    c+=1
print(c)

### FIXED CODE ###

n,d = map(int,input().split(" "))
d *= d
c = 0
for i in range(n):
  a,b =map(int,input().split(" "))
  if(a**2 + b**2 <= d):
    c += 1
print(c)
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
A.append(0)

Sum = 0
for i in range(N+1):
    Sum += abs(A[i+1] - A[i])

for i in range(1, N+1):
    if (A[i-1] < A[i] < A[i+1]) or (A[i+1] < A[i] < A[i-1]):
        ans = Sum
    elif A[i] > A[i-1]:
        ans = Sum - 2 * abs(A[i] - max(A[i-1], A[i+1]))
    elif A[i] < A[i-1]:
        ans = Sum - 2 * abs(A[i] - min(A[i-1], A[i+1]))
    print(ans)


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
A.append(0)

Sum = 0
for i in range(N+1):
    Sum += abs(A[i+1] - A[i])

for i in range(1, N+1):
    if (A[i-1] < A[i] < A[i+1]) or (A[i+1] < A[i] < A[i-1]):
        ans = Sum
    elif A[i] > A[i-1]:
        ans = Sum - 2 * abs(A[i] - max(A[i-1], A[i+1]))
    elif A[i] < A[i-1]:
        ans = Sum - 2 * abs(A[i] - min(A[i-1], A[i+1]))
    else:
        ans = Sum
    print(ans)
for _ in range(int(input())):
    a=int(input())+int(input())
    print(a if a<10**80else'overflow')

### FIXED CODE ###

for _ in range(int(input())):
    a=int(input())+int(input())
    print(a if a < 10**80 else 'overflow')
if __name__ == '__main__':
    N, numbers = get_input()
    s = [0]
    for i in range(N):
        s.append(s[-1] + numbers[i])
    s.sort()
    print(s)
    count = 1
    result = 0
    for i in range(N):
        if(s[i] == s[i+1]):
            count += 1
        else:
            result += count * (count -1 ) // 2
            count = 1
    result += count * (count -1 ) // 2
    print(result)

### FIXED CODE ###

def get_input():
    N = int(input())
    numbers = [int(i) for i in input().split()]
    return N, numbers

def DPsolve(N, numbers):
    count = 0
    dp = [[1 for i in range(len(numbers))] for j in range(len(numbers))]
    for i in range(N):
        for j in range(N-i):
            if j == 0:
                dp[i][j] = numbers[i]
            else:
                dp[i][j] = dp[i][j-1] + numbers[i+j]
            if dp[i][j] == 0:
                count += 1
    return dp, count

if __name__ == '__main__':
    N, numbers = get_input()
    s = [0]
    for i in range(N):
        s.append(s[-1] + numbers[i])
    s.sort()
    count = 1
    result = 0
    for i in range(N):
        if(s[i] == s[i+1]):
            count += 1
        else:
            result += count * (count -1 ) // 2
            count = 1
    result += count * (count -1 ) // 2
    print(result)
import copy
n=int(input())
a=list(map(int,input().split()))
a2=copy.copy(a)
for i in a2:
    a.append(i)
    ad=a[i+1:n+i]
    ans = 0                                                                            adset=list(set(ad))
    for j in adset:
        k = ad.count(j)                                                                    if(k >= 2):                                                                           ans += (k*(k-1))//2                                                             else:
            continue
    print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
aset=list(set(a))
ans=0
al=[0]*200000
for i in a:
    al[i]+=1
for j in aset:
    k=al[j]
    ans+=(k*(k-1))//2
for u in a:
    print(ans-al[u]+1)
from sys import stdin
from collections import deque

n,m=map(int,input().split())
ab=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,readline().split())
    a-=1
    b-=1
    ab[a].append(b)
    ab[b].append(a)
queue=[0]
ans=[-1]*n
ans[0]=0
while len(queue)!=0:
    now_check=queue.pop(0)
    for i in ab[now_check]:
        if ans[i]==-1:
            queue.append(i)
            ans[i]=now_check
print('Yes')
for i in range(1,n):
    print(ans[i]+1)

### FIXED CODE ###

from sys import stdin
from collections import deque

n,m=map(int,input().split())
ab=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,stdin.readline().split())
    a-=1
    b-=1
    ab[a].append(b)
    ab[b].append(a)
queue=[0]
ans=[-1]*n
ans[0]=0
while len(queue)!=0:
    now_check=queue.pop(0)
    for i in ab[now_check]:
        if ans[i]==-1:
            queue.append(i)
            ans[i]=now_check
print('Yes')
for i in range(1,n):
    print(ans[i]+1)
def lcs_size():
  X = input()
  Y = input()
  
  a = len(X)
  b = len(Y)
  
  c = [[0 for i in range(a+1)] for j in range(b+1)]
  maxl = 0
  for i in range(a):
    for j in range(b):
      if X[i] == Y[j]:
        c[i][j+1] = c[i][j] + 1
      elif c[i+1][j+1] < c[i][j+1]:
        c[i][j+1] = c[i][j+1]
      maxl = max(maxl, c[i][j+1])
  
  return maxl

q = input()

for i in range(q):
  print lcs_siz()

### FIXED CODE ###

def lcs_size():
  X = raw_input()
  Y = raw_input()
  a = len(X)
  b = len(Y)
  z2 = [0 for i in range(b+1)]

  for i in range(a):
    ch = X[i]
    z1 = z2 + []
    for j in range(b):
      if ch == Y[j]:
        z2[j+1] = z1[j] + 1
      elif z2[j+1] < z2[j]:
        z2[j+1] = z2[j]

  return z2[-1]

q = input()
for k in range(q):
  print lcs_size()
a,b = map (int, input().split)
if a<b:
    print("a < b")
    elif a>b:
        print("a > b")
        else a == b:
            print("a == b")


### FIXED CODE ###

a,b = map (int, input().split())
if a<b:
    print("a < b")
elif a>b:
    print("a > b")
else:
    print("a == b")
res = {}
for i in range(-100, 100):
    for j in range(-100, 100):
        ans = i ** 5 - j ** 5
        res[ans] = (i, j)
n = int(input())
print(res[n][0], res[n][1])


### FIXED CODE ###

res = {}
for i in range(-500, 500):
    for j in range(-500, 500):
        ans = i ** 5 - j ** 5
        res[ans] = (i, j)
n = int(input())
print(res[n][0], res[n][1])
n = int(input())
s = input()
ls = []

for i in range(1,n-1):
  
  dic_f = {}
  dic_l = {}
  former = s[:i]
  latter = s[i+1:]
  counter = 0
  
  for j in range(len(former)):
    if former[j] not in dic_f.keys():
      dic_f[former[j]] = 1
      
  for j in range(len(latter)):
    if latter[j] not in dic_l.keys():
      dic_l[latter[j]] = 1
      
  for j in dic_f.keys():
    if j in dic_l.keys():
      counter += 1
  ls.append(counter)

print(max(ls))

### FIXED CODE ###

n = int(input())
s = input()
dic_1 = {}
dic_2 = {}
ls = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans = 0
for j in range(26):
    dic_1[ls[j]] = 0
    dic_2[ls[j]] = 0
for i in range(1,n-1):
    s1 = s[:i]
    s2 = s[i:]
    tmp = 0
    for j in range(26):
        dic_1[ls[j]] = 0
        dic_2[ls[j]] = 0
    for j in range(len(s1)):
        dic_1[s1[j]] = 1
    for j in range(len(s2)):
        dic_2[s2[j]] = 1
    for j in range(26):
        tmp += dic_1[ls[j]] * dic_2[ls[j]]
    ans = max(ans,tmp)
print(ans)
import numpy as np
import sys
input = sys.stdin.readline
n=int(input())
a = tuple(map(int,input().split()))
cnt = [0,0,0] #1個の個数、二個の個数、三個の個数
for i in range(n):
    cnt[a[i]-1] += 1
    
def f(i,j,k):
    if [i,j,k] == [0,0,0]:
        return 0.0
    if dp[i][j][k] != 0.0:
        return dp[i][j][k]
    tmp = 0.0
    if i>0:
        tmp += f(i-1,j,k)*float(i)/float(i+j+k)
    if j>0:
        tmp += f(i+1,j-1,k)*float(j)/float(i+j+k)
    if k>0:
        tmp += f(i,j+1,k-1)*float(k)/float(i+j+k)
    tmp += float(n)/float(i+j+k)
    
 
    dp[i][j][k] = tmp
    return tmp
dp = np.zeros((n+1,n+1,n+1))
#dp = [[[0.0 for i in range(n+1)] for j in range(n+1)] for k in range(n+1)]
 
print(f(cnt[0],cnt[1],cnt[2]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = tuple(map(int,input().split()))
c1 = a.count(1)
c2 = a.count(2)
c3 = a.count(3)

dp = [[[0.0]*(n+1) for i in range(n+1)] for j in range(n+1)] 
dp[0][0][0] = 0
for i in range(c3+1):
    for j in range(c2+c3-i+1):
        for k in range(n-i-j+1):
            if i == j == k == 0:
                continue
            tmp = n
            if k != 0:
                tmp += k*dp[k-1][j][i]
            if j != 0:
                tmp += j*dp[k+1][j-1][i]
            if i != 0:
                tmp += i*dp[k][j+1][i-1]
            dp[k][j][i] = tmp/(i+j+k)

print(dp[c1][c2][c3])
# Problem B - Ringo's Favorite Numbers

# input
D, N = map(int, input().split())

# initialization
ans = 0
tmp_list = []
tmp = 100**D

# calc
i = 1
while not i>N:
    ans = tmp * i
    if not ans%(tmp*100)==0:
        tmp_list.append(ans)
        i = i + 1
    else:
        i = i + 1

#output
ans = tmp_list[N-1]
print(ans)


### FIXED CODE ###

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


for i in range(1, 100000000):
    if i % (100 ** d) == 0 and i % (100 * 100 ** d) != 0:
        n -= 1
    if n == 0:
        print(i)
        exit()
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


class GaussElimination:
    def __init__(self, a):
        self.a = a
        self.n = len(self.a)

    def exec(self):
        try:
            for k in range(self.n - 1):
                for i in range(k + 1, self.n):
                    d = self.a[i][k] / self.a[k][k]
                    for j in range(k + 1, self.n + 1):
                        self.a[i][j] -= self.a[k][j] * d
            for i in range(self.n - 1, -1, -1):
                d = self.a[i][self.n]
                for j in range(i + 1, self.n):
                    d -= self.a[i][j] * self.a[j][self.n]
                self.a[i][self.n] = d / self.a[i][i]
        except Exception:
            raise


def main():
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    matrix = [[0] * (N + 1) for _ in range(N)]
    for i in range(N):
        if i == N - 1:
            matrix[N - 1][0] = 1
            matrix[N - 1][N - 1] = 1
        else:
            matrix[i][i] = 1
            matrix[i][i + 1] = 1
        matrix[i][N] = A[i]
    gauss = GaussElimination(matrix)
    gauss.exec()
    ans = []
    for i in range(N):
        ans.append(str(int(gauss.a[i][N] * 2)))
    print(" ".join(ans))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    tmp = 0
    ans = [0] * n
    f = 1
    for i in a:
        tmp += f * i
        f = f * -1
    ans[0] = tmp
    ans[n - 1] = 2 * a[n - 1] - ans[0]
    for i in range(n - 2, 0, -1):
        ans[i] = 2 * a[i] - ans[i + 1]

    print(" ".join([str(i) for i in ans]))


if __name__ == "__main__":
    main()
N, M= int(input().join(' '))

items = [int(i) for i in input().join(' ')]
items.sort()
total = sum(items)

flag = 1
for i in range(M):
  if 1 // (4 * M) >= items[i]:
    pass
  else:
    flag = 0
if not flag:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N,M = [int(i) for i in input().split()]

items = [int(i) for i in input().split()]
items.sort(reverse=True)
total = sum(items)

flag = 1
for i in range(M):
  if total / (4 * M) <= items[i]:
    pass
  else:
    flag = 0
if flag:
  print('Yes')
else:
  print('No')
from math import gcd

n = int(input())
a = list(map(int, input().split()))
fromLeft = [0] * n
fromLeft[0] = a[0]
fromRight = [0] * n
fromRight[0] = a[n - 1]
for i in range(1, n):
    fromLeft[i] = gcd(fromLeft[i - 1], a[i])
    fromRight[i] = gcd(fromRight[i - 1], a[n - i - 1])
ret = fromLeft[n - 1]
for i in range(n):
    if i == 0:
        curGcd = fromRight[n - 2]
    elif i == n - 1:
        curGcd = fromLeft[n - 2]
    else:
        curGcd = gcd(fromLeft[i - 1], fromRight[n - i - 2])
    ret = max(ret, curGcd)
print(ret)


### FIXED CODE ###

def gcd(x, y):
    while (y):
        x, y = y, x % y
    return x

n = int(input())
a = list(map(int, input().split()))
fromLeft = [0] * n
fromLeft[0] = a[0]
fromRight = [0] * n
fromRight[0] = a[n - 1]
for i in range(1, n):
    fromLeft[i] = gcd(fromLeft[i - 1], a[i])
    fromRight[i] = gcd(fromRight[i - 1], a[n - i - 1])
ret = fromLeft[n - 1]
for i in range(n):
    if i == 0:
        curGcd = fromRight[n - 2]
    elif i == n - 1:
        curGcd = fromLeft[n - 2]
    else:
        curGcd = gcd(fromLeft[i - 1], fromRight[n - i - 2])
    ret = max(ret, curGcd)
print(ret)
import numpy as np
s = np.array([ord(c) for c in input()])
t = np.array([ord(c) for c in input()])
print(np.count_nonzero(s - t))

### FIXED CODE ###

import numpy as np
s = np.array([ord(c) for c in input()])
t = np.array([ord(c) for c in input()])
print(np.count_nonzero(s - t))
h, w = map(int, input().split())



m = []

for i in range(h):
    l = list(input())
    m.append([ '#' if i=='#' else 0 for i in l])

for i in range(h):
    for j in range(w):
        if m[i][j] == '#':
            for u in range(3):
                for v in range(3):
                    if u==1 and v==1:
                        pass
                    else:
                        try:
                            m[i + u -1][j + v-1] += 1
                        except:
                            pass





for l in r:
    s = map(str, l)
    print(''.join(s))


### FIXED CODE ###

h, w = map(int, input().split())

m = []

for i in range(h):
    l = list(input())
    m.append([ '#' if i=='#' else 0 for i in l])

for i in range(h):
    for j in range(w):
        if m[i][j] == '#':
            for u in range(3):
                for v in range(3):
                    if u==1 and v==1:
                        pass
                    else:
                        try:
                            y = i+u-1
                            x = j+v-1
                            if y < 0 or x < 0:
                                continue

                            if m[y][x] != '#':
                                m[y][x] += 1

                        except:
                            pass

for l in m:
    s = map(str, l)
    print(''.join(s))
input()**3

### FIXED CODE ###

x=int(input())
print(x**3)
import math

r = int(input())
a = math.pi*r*r
l = 2*math.pi*r

print("{:.6f}".format(a),"{:.6f}".format(l))

### FIXED CODE ###

import math

r = float(input())
a = math.pi*r*r
l = 2*math.pi*r

print("{:.6f}".format(a),"{:.6f}".format(l))
max_test = 100000
for i in range(max_test):
  if i * X % 360 == 0:
    break

return I+1

### FIXED CODE ###

X= int(input())
max_test = 100000
for i in range(1,max_test):
  if i * X % 360 == 0:
    break

print(i)
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
Ps = list(map(int, input().split()))
Cs = list(map(int, input().split()))
scores = list()
max_list = list()
for i in range(N):
    next = Ps[i] - 1
    scores = [Cs[next]]
    while next != i:
        next = Ps[next] - 1
        scores.append(Cs[next]+scores[-1])
    l = len(scores)
    if scores[-1] < 0 or l >= K:
        max_list.append(max(scores[:K]))
    else:
        a, b = divmod(K, l)
        max_list.append(a*scores[-1] + max(scores[:b]))
print(max(max_list))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
N, K = map(int, input().split())
Ps = list(map(int, input().split()))
Cs = list(map(int, input().split()))
max_list = list()
for i in range(N):
    next = Ps[i] - 1
    scores = [Cs[next]]
    while next != i:
        next = Ps[next] - 1
        scores.append(scores[-1] + Cs[next])
    l = len(scores)
    if K <= l:
        max_list.append(max(scores[:K]))
    else:
        if scores[-1] < 0:
            max_list.append(max(scores))
        else:
            a, b = divmod(K, l)
            cand1 = 0
            if b!=0:
                cand1 = a*scores[-1] + max(scores[:b])
            cand2 = (a-1)*scores[-1] + max(scores)
            max_list.append(max(cand1, cand2))
    #print(scores)
print(max(max_list))
a,b=(int(x) for x in input().split())
lista=[]
listb=[]
for numa in range(a+1):
  lista.append(numa*2)
for numb in range(a+1):
  listb.append(numb*4)
listb.reverse()
count=0
combined1 = [x+y for (x, y) in (lista, listb)]
for num in combined1:
  if num==b:
    count+=1
if count>0:
  print("Yes")
else: 
  print("No")

### FIXED CODE ###

a,b=(int(x) for x in input().split())
lista=[]
listb=[]
for numa in range(a+1):
  lista.append(numa*2)
for numb in range(a+1):
  listb.append(numb*4)
listb.reverse()
count=0
combined1 = [x+y for (x, y) in zip(lista, listb)]
for num in combined1:
  if num==b:
    count+=1
if count>0:
  print("Yes")
else: 
  print("No")
N = int(input())

n = [0]*(N+1)
for i in range(2, N+1):
    for j in range(2, i+1):
        while i%j == 0:
            i//=j
            n[j] += 1

def num(m):
return len(list(filter(lambda x: x>=m-1, e)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)14+num(5)*(num(5)-1)*(num(3)-2)//2)

### FIXED CODE ###

N = int(input())

n = [0]*(N+1)
for i in range(2, N+1):
    for j in range(2, i+1):
        while i%j == 0:
            i//=j
            n[j] += 1

def num(m):
    return len(list(filter(lambda x: x>=m-1, n)))

print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)+num(5)*(num(5)-1)*(num(3)-2)//2)
a,b=map(int,input().split())
if a>=9 or b>=9 :
  print(-1)
else a<=9 and b<=9 :
  print(a*b)

### FIXED CODE ###

a,b=map(int,input().split())
if a>=10 or b>=10:
  print(-1)
else:
  print(a*b)
S,K,c=input(),int(input()),0
while c<K and S[c]=='1':c+=1
print(S[c])


### FIXED CODE ###

S = input()
K = int(input())
# print(S, K)
for i in range(len(S)):
    s = S[i]
    if i >= K:
        break
    if s != '1':
        print(s)
        exit()
print('1')
H, W = sorted(map(int,input().split()))
C = [input() for _ in range(H)]

ans = "Yes"
for i in range(H-1):
  for j in range(W-1):
    if(C[i][j] == "#"):
      if(i != 0 and C[i-1][j] == "#"):
        continue
      if(i != H and C[i+1][j] == "#"):
        continue
      if(j != 0 and C[i][j-1] == "#"):
        continue
      if(j != W and C[i][j+1] == "#"):
        continue
      ans = "No"
print(ans)

### FIXED CODE ###

H, W = map(int,input().split())
HW = [input() for _ in range(H)]

ans = "Yes"
for i in range(H-1):
  for j in range(W-1):
    if(HW[i][j] == "."):
      continue
    if(i != 0 and HW[i-1][j] == "#"):
      continue
    if(j != 0 and HW[i][j-1] == "#"):
      continue
    if(j != H and HW[i+1][j] == "#"):
      continue
    if(j != W and HW[i][j+1] == "#"):
      continue
    ans = "No"
print(ans)
import math
n,x = map(int, input().split())
list_x = list((map(int, input().split())))
list_x.append(x)
list_x.sort()
list_dist = []
for i in range(0,n):
    list_dist.append(list_x[i+1] - list_x[i])
gcd1 = list_dist[0]
for i in range(1,n):
    gcd1 = math.gcd(gcd1, list_dist[i])
print(gcd1)


### FIXED CODE ###

def gcd(x,y):
    if x < y:
        (x,y) = (y,x)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

n,x = map(int, input().split())
list_x = list((map(int, input().split())))
list_x.append(x)
list_x.sort()
list_dist = []
for i in range(0,n):
    list_dist.append(list_x[i+1] - list_x[i])
gcd1 = list_dist[0]
for i in range(1,n):
    gcd1 = gcd(gcd1, list_dist[i])
print(gcd1)
# 初期入力
N = int(input())
A = list(map(int, input().split()))


x = [  A[i]^A[j] for i in range(N-1) for j in range(i+1,N) ]
kotae =sum(x) % (10**9 +7)
print(kotae)

### FIXED CODE ###

from itertools import product
#初期入力
N = int(input())
testimony ={j:[-1 for i in range(N)] for j in range(1,N+1)}
A=[]
for i in range(1,N+1):
    a = int(input())
    A.append(a)
    for j in range(a):
        x,y = list(map(int, input().split()))
        testimony[i][x-1] =y

#各人が正直か不親切かを仮定する。仮定(Assumption)が矛盾するか、判定を全探索

assumption_correct =[]
for assumption in product([1,0], repeat=N):
    count_2=0
    for i in range(N):      #証言する人        
        if assumption[i] ==1:
            count =0 
            for j in range(N):  #証言受けた人 
                         
                if testimony[i+1][j] ==assumption[j]:
                    count +=1
            if count == A[i]:
                count_2 +=1
    if count_2 ==sum(assumption):
        assumption_correct.append(sum(assumption))
print(max(assumption_correct))