Harryxun/stf_run huggingface dataset:
n,k = map(int,input().split())
A = [int(input()) for _ in range(n)]
B = []
b = 1
ans = 1
while ans:
  a = b
  b = A[a-1]
  B.append(b)
  if len(B) == len(A):
    ans = 0
  else:
    continue

print(B[k-1])


### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)
n = int(input())
x = n*(n-1)*2(10**(n-2))

print(x%(10**9 + 7))

### FIXED CODE ###

n = int(input())

x = 10**n - 2*(9**n) + 8**n
print(x%(10**9+7))
k = int(input())
alist =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 . split(, )
print(alist[k-1])


### FIXED CODE ###

k = int(input())
alist = [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]
print(alist[k-1])
X,Y=map(int,input().split())
if 2＊X<=Y and Y<=4＊X and Y%2==0:
  print('yes')
else:print('no')

### FIXED CODE ###

X,Y=map(int,input().split())
if 2*X <= Y and Y <= 4*X and Y%2 == 0:
  print('Yes')
else:print('No')
N = int(input())
if N==2:
    assert False
print(-1)


### FIXED CODE ###

N = int(input())
if N==2:
    print(-1)
    exit()
if N==3:
    print("""aa.
..b
..b""")
    exit()
P4 = """abcc
abdd
ccab
ddab"""
P5 = """abbaa
a..db
b..db
bcc.a
aabba"""
P6 = """aa.ccd
..bd.d
..bdcc
ccdaa.
d.d..b
dcc..b"""
P7 = """.ccbbaa
c...ccd
c...d.d
b...dcc
bccd...
ad.d...
adcc..."""
P = [P4, P5, P6, P7]
def construct(L):
    P_split = [p.split() for p in P]
    ans = []
    offset = 0
    for l in L:
        r = N-offset-l
        for p in P_split[l-4]:
            ans.append("."*offset + p + "."*r)
        offset += l
    return "\n".join(ans)
def sep(n):  # 4 と 5 に分ける
    if n==6:
        return [6]
    elif n==7:
        return [7]
    elif n==11:
        return [5, 6]
    res = [4] * (n//4)
    for i in range(n%4):
        res[i] += 1
    return res
print(construct(sep(N)))
while True:
    a, b = map(int, input().split())
    if a <= 0 or b <= 0:
        break
    elif a > 10 **9 or b > 10 **9:
        break
    else:
        d = int(a/b)
        r = int(a%b)
        f = float(a/b)
        print(d, r, "{0:01.5f}".format(f))

### FIXED CODE ###

while True:
    a, b = map(int, input().split())
    if a <= 0 or b <= 0:
        break
    elif a > 10 **9 or b > 10**9:
        break
    else:
        d = int(a/b)
        r = int(a%b)
        f = float(a/b)
        print(d, r, "{0:01.5f}".format(f))
        break
"""
ポラード・ロー法で素因数分解
"""
n,target=map(int,input().split())
seed = 0

# 最大公約数
def gcd(a, b):
    if a<b:
        return gcd(b, a)
    while b>0:
        a, b = b, a%b
    return a

# 素数判定
def isprime(n):
    if n<2:
        return False
    for m in range(2, int(n**0.5+1)):
        if n%m==0:
            return False
    return True

# 疑似乱数発生器（らしい）
def f(n):
    ret = n**2+seed
    return ret%target

# 素数になるまで割る？
def factoring(n, _seed = 3):
    if isprime(n):
        return n
    x, y, d = 2, 2, 1
    tmp = n
    seed = _seed
    while d==1:
        x = f(x)
        y = f(f(y))
        dif = x-y if x>y else y-x
        d = gcd(dif, tmp)
        seed+=1

    seed = 0
    if(d%2==0):
        return 2
    if isprime(d) is False:
        return factoring(d, seed+1)
    return factoring(d, 1)

# メイン
def factors():
    dic = {}
    tmp = target
    if(isprime(tmp)):
        dic[tmp] = 1
        return dic

    ret = factoring(tmp)
    while tmp/ret is not 0:
        if ret in dic.keys():
            dic[ret]+=1
        else:
            dic[ret]=1
        tmp = int(tmp/ret)
        if tmp==1:
            break
        ret = factoring(tmp)

    return dic

def main():
    a=factors()
    res=1
    for b,c in a.items() :
        if c >= n : res *= b
    print(res)
    

if __name__=='__main__':
    main()

### FIXED CODE ###

n,p = list(map(int,input().split())) 
i = a = o = 1
m = round(p**(1/n))
for i in range(m,0,-1):
    a = i**n
    if p%a==0:
        print(i)
        exit()
N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int, input().split())
    G[a-1].append([b-1,i])

ans = [None]*(N-1)

def func(cur,color):
    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        func(to, cnt)
        cnt += 1
        
func(0, 0)
print(max(ans))
print(*ans, sep="\n")

### FIXED CODE ###

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

n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append([b,i])

ans = [None]*(n-1)
def rec(cur,color):
    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1
rec(0, 0)
print(max(ans))
print(*ans, sep="\n")
N=int(input())
C=0
for i in range(1,N):
  if i**2<N:
    C=i**2
  elif i**2=N:
    C=i**2
    break
  elif i**2>N:
    break
print(C)

### FIXED CODE ###

N=int(input())
C=0
if N==1:
  print(1)
  exit()
for i in range(1,N):
  if i**2<N:
    C=i**2
  elif i**2==N:
    C=i**2
    break
  elif i**2>N:
    break
print(C)
import collections
n=int(input())
arr=list(map(int,input()))
q=collections.deque()
for i in range(n):
  if i%2==0:
    q.append(arr[i])
  else2
  q.appendleft(arr[i])
if i%2==1:
  q=list(q)[::-1]
print(' '.join(map(str,q)))

### FIXED CODE ###

import collections
n=int(input())
arr=list(map(int,input().split()))
q=collections.deque()
for i in range(n):
  if i%2==0:
    q.append(arr[i])
  else:
    q.appendleft(arr[i])
if n%2==1:
  q=list(q)[::-1]
print(' '.join(map(str,q)))
a,b,c = [int(input().split()) for i in range(3)]
if a<b and b<c:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

a,b,c = map(int,input().split())
if a<b and b<c:
    print('Yes')
else:
    print('No')
# -*- coding: utf-8 -*-
# input
a = int(input())
s = 0
bc = 0
ac = 0
tc = 0
for i in range(a):
    t = input()
    s += t.count('AB')
    if t[:1] == 'B':
        bc += 1
    if t[-1:] == 'A':
        ac += 1
    if t[:1] == 'B' or t[-1:] == 'A':
        tc += 1
if min(bc, ac) == tc and tc > 0:
    o = s + min(bc, ac)-1
else:
    o = s + min(bc, ac)
print(o)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# input
#a = int(input())
#a,b = input()
a, b = map(int, input().split())
#a, b, c = input().split()
print(a-b+1)
if S=='Sunny':
  print('Cloudy')
elif S=='Cloudy':
  print('Rainy')
else:
  print('Sunny')


### FIXED CODE ###

S=input()
if S=='Sunny':
	print('Cloudy')
elif S=='Cloudy':
	print('Rainy')
else:
	print('Sunny')
n=int(input())
a=list(map(int,input().split()))
ans=0
data=[0]*(n-1)
for i in range(n-1):
  data[i]=a[i+1]-a[i]
for i in range(1,n-2):
  if data[i]<0:
    if data[i-1]>0 or data[i+1]>0:
      ans+=1
if data[0]<0:
  if data[1]>0:
    ans+=1
if data[n-2]<0:
  if data[n-3]>0:
    ans+=1
print(ans+1)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
i=1
up=0
down=0
while i<n:
  if up==down:
    if a[i]>a[i-1]:
      up+=1
      down=0
    elif a[i]<a[i-1]:
      down+=1
      up=0
    elif a[i]==a[i-1]:
      up+=1
      down+=1
  elif up==0 and down!=0:
    if a[i]<=a[i-1]:
      down+=1
    else:
      ans+=1
      down=0
  elif down==0 and up!=0:
    if a[i]>=a[i-1]:
      up+=1
    else:
      ans+=1
      up=0
  i+=1
print(ans+1)
n11, n12, n13 = (input().split())
n21, n22, n23 = (input().split())
n31, n32, n33 = (input().split())
lines = [[n11,n12,n13],
         [n21,n22,n23],
         [n31,n32,n33],
         [n11,n21,n31],
         [n12,n22,n32],
         [n13,n23,n33],
         [n11,n22,n33],
         [n13,n22,n31]]
nums = {}
for i in range(int(input())):
  nums[input()] = 0
flag = False
for l in lines:
  if l[0] in nums:
    if l[1] in nums:
      if l[2] in nums:
        flag = True
if flag:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

import math
s = input()
s = int(s)
s = s/2
s = math.ceil(s)
print(s)
a = list(map(int,input().split()))
N = a[0]
K = a[1]

b = list(map(int,input().split()))

for i in range(len(b)):
    for j in range(len(b)):
        if b[i]<b[j]:
            x = b[i]
            b[i] = b[j]
            b[j] = x
c = 0
for k in b:
    if k < K:
        break
    c += 1

print c

### FIXED CODE ###

a = list(map(int,input().split()))
N = a[0]
K = a[1]

b = list(map(int,input().split()))
c = 0
for i in b:
    if i >= K:
        c += 1
print(c)
def dist(r, c):
    return min(r, H - r - 1, c, W - c - 1)

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

for r in range(H):
    for c in range(W):
        if A[r][c] == 'S':
            sr = r
            sc = c

dxy = [(1, 0), (0, -1), (-1, 0), (0, 1)]
pos = [(sr, sc)]
dic = {(sr, sc): K}
cnt = 0
ans = H * W
i = 0
while i < len(pos):
    r0, c0 = pos[i]
    d0 = dist(r0, c0)
    ans = min(ans, (d0 + K - 1) // K + 1)
    m0 = dic[(r0, c0)]
    if 0 < m0:
        m = m0 - 1
        for (dx, dy) in dxy:
            r = r0 + dy
            c = c0 + dx
            d = dist(r, c)
            if 0 <= r < H and 0 <= c < W and A[r][c] != '#' and (r, c) not in dic:
                pos.append((r, c))
                dic[(r, c)] = m
    i += 1

print(ans)

### FIXED CODE ###

A, B, C = map(int, input().split())
dict = {}
ans = 0
while ans < 1000000:
    tpl = tuple(sorted([A, B, C]))
    if tpl in dict:
        ans = -1
        break
    elif A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break
    dict[tpl] = True
    A, B, C = (B + C) // 2, (C + A) // 2, (A + B) // 2
    ans += 1
print(ans)
a,b=map(int,input().split())
c,d=map(int,input().split())
print(int(((a-c)*(b-d)))

### FIXED CODE ###

a,b=map(int,input().split())
c,d=map(int,input().split())
print(int((a-c)*(b-d)))
def main():
    import sys
    input = sys.stdin.readline
    
    INF = 10 ** 18

    N, M = map(int, input().split())

    G = [[] for _ in range(N + 1)]
    for _ in range(M):
        L, R, C = map(int, input().split())
        G[L].append([C, R])
        G[R].append([C, L])

    for i in range(1, N):
        G[i + 1].append([0, i])

    d = [INF] * (N + 1)

    def dijkstra(s):
        from heapq import heappop. heappush
        d[s] = 0
        pque = []
        heappush(pque, [0, s])
        
        while pque:
            p = heappop(pque)
            v = p[1]
            if d[v] < p[0]:
                continue
            for i in range(len(G[v])):
                e = G[v][i]
                if d[e[1]] > d[v] + e[0]:
                    d[e[1]] = d[v] + e[0]
                    heappush(pque, [d[e[1]], e[1]])

    dijkstra(1)

    print (-1 if d[-1] == INF else d[-1])

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

N, M = map(int, input().split())

lst = [tuple(map(int, input().split())) for _ in range(M)]
lst.sort(key = lambda x: x[1])
lst.sort(key = lambda x: x[0])

#セグメント木
#次の2つの処理をO(log N)で実施することができる
# s, tが与えられた時、区間[s, t)の最小値を求める
# i, xが与えられた時、a_iの値をxに変更する

INIT = 10 ** 18 #初期値 答えに関係ないもの
MAX_N = 10 ** 6 #与えられる要素数の最大
# INIT = 100
data = [INIT] * (2 * MAX_N - 1) #MAX_Nで初期化

#ここに機能をもたせる
def func(vl, vr):
    return min(vl, vr)

def init(n_):
    #簡単のため要素数を2のべき乗に
    n = 1
    while n < n_:
        n *= 2
    return n

# N = int(input()) #配列の数
n = init(N)

def update(k, a): #k番目の値をaに変更 0-index
    # B[a] = k
    k += n - 1
    data[k] = a
    while k > 0: #登りながら更新
        k = (k - 1)//2
        data[k] = func(data[k * 2 + 1], data[k * 2 + 2])

def query(a, b, k = 0, l = 0, r = n):
    if r <= a or b <= l:
        return INIT
    if a <= l and r <= b:
        return data[k]
    else:
        vl = query(a, b, k * 2 + 1, l, (l + r)//2)
        vr = query(a, b, k * 2 + 2, (l + r)//2, r)
        return func(vl, vr)

def initialize(A): #リストAを与えて初期化する
    for i, a in enumerate(A):
        data[i + n - 1] = a
        # B[a] = i
    for i in range((2 * n - 3)//2, -1, -1):
        data[i] = func(data[i * 2 + 1], data[i * 2 + 2])

# def index(a): #要素aがもとのどこに保存されているかを返す関数
#     return B[a]

def value(index): #indexが与えられた時、index番目の値を得る
    return data[index + n - 1]

#初期値の入力
D = [INIT] * N
D[0] = 0
# B = dict() #同じ要素がないのが前提 0-index管理
initialize(D)

#クエリの数
# print (lst)
# print (D)
for a, b, c in lst:
    a -= 1
    b -= 1
    tmp = query(a, b)
    if D[b] > tmp + c:
        D[b] = tmp + c
        update(b, tmp + c)
    # print (D)

# print (D)
print (-1 if D[N - 1] == INIT else D[N - 1])
n,k = map(int,input().split())

vl = list(map(int,input().split()))

dpa = [[0 for j in range(k+2)] for i in range(k+2)]
dpb = [[0 for j in range(k+2)] for i in range(k+2)]
suma = []
sumb = []
for i in range(k):
    suma += [vl[i]]
    sumb += [vl[-i-1]]
    suma = sorted(suma)
    sumb = sorted(sumb)
    for j in range(min(i+1, k+1-i)):
        dpa[i][j] = sum(suma[j:])
        dpb[i][j] = sum(sumb[j:])
    
ans = 0
for a in range(k+1):
    for b in range(k+1-a):
        for c in range(min(a+1, k+1-a-b)):
            for d in range(min(b+1, k+1-a-b-c)):
                tmp = dpa[a-1][c] + dpb[b-1][d]
                if tmp > ans:
                    ans = tmp

print(ans)
    

### FIXED CODE ###

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

vl = list(map(int,input().split()))

ans = 0
for a in range(k+1):
    suba = vl[:a]
    for b in range(min(n+1-a, k+1-a)):
        subb = vl[-b:]
        if b == 0:
            subb = []
        sub = suba + subb
        ssub = sorted(sub)
        for _ in range(k-a-b):
            if len(ssub) == 0:
                break
            if ssub[0] < 0:
                ssub.pop(0)
            else:
                break
        if sum(ssub) > ans:
            ans = sum(ssub)

print(ans)
A,B = int(input().split())
print(max([A+B,A-B,A*B]))

### FIXED CODE ###

A,B = map(int, input().split())
print(max([A+B,A-B,A*B]))
import sys
import numpy as np
from fractions import gcd
a, b = [int(i) for i in sys.stdin.readline().split()]
_gcd = gcd(a,b)
memo_ls = np.zeros(_gcd)
#memo_set = set()
cnt = 0
for i in range(2, _gcd):
    if _gcd % i == 0 and memo_ls[i-1] != 1:
        memo_ls[i-1::i] = 1
        cnt += 1
        #memo_set.add(i)
#print(memo_set)
print(cnt + 1)

### FIXED CODE ###

import sys
from fractions import gcd
def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a

def main(a, b):
    #a, b = [int(i) for i in sys.stdin.readline().split()]
    _gcd = gcd(a,b)
    #memo_ls = [0 for i in range(_gcd)]
    #memo_set = set()
    cnt = 0
    if _gcd == 1:
        print(1)
    else:
        res = prime_factorize(_gcd)
        print(len(res) + 1)
if __name__ == "__main__":
    a, b = [int(i) for i in sys.stdin.readline().split()]
    main(a, b)
_, k = input().split()
 
prices = list(input().split().map(lambda x : int(x)))
 
prices.sort()
 
sum = 0
for i in range(int(k)):
	sum += prices[i]
print(sum)

### FIXED CODE ###

_, k = input().split()
 
prices = list(map(lambda x : int(x), input().split()))
 
prices.sort()
 
sum = 0
for i in range(int(k)):
	sum += prices[i]
print(sum)
S = {i:list(input()) for i in "abc"}
while S[s]: s=S[s].pop(0)
print(s.upper())

### FIXED CODE ###

a = list(input())
b = list(input())
c = list(input())
s = a.pop(0)
ans = "a"
while 1:
    if s == "a":
        if a: s = a.pop(0)
        else: break
    elif s=="b":
        if b: s = b.pop(0)
        else: break
    else:
        if c: s = c.pop(0)
        else: break
print(s.upper())
N=int(input())
a=list(map(int,input().split()))
n=0
flag = 1

while flag:
	for i in range(len(a)):
		if a[i]%2==0:
			a[i]=a[i]/2
		else:
			flag = 0
	n=n+1

print(n-1)

### FIXED CODE ###

i=input()
print(i.count('1'))
s = input()
c = len(s)
f = 0
for i in s:
  if i == "C":
    c = min(c,i)
  elif i == "F":
    f = max(f,i)
if c < f:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

s = input()
c = len(s)
f = 0
for x,i in enumerate(s):
  if i == "C":
    c = min(c,x)
  elif i == "F":
    f = max(f,x)
if c < f:
  print("Yes")
else:
  print("No")
import math

n, k = map(int, input().split())
A = list(map(int, input().split()))

l = 0
r = 10**9+1

while l < r:
    mid = (l+r)//2
    count = 0
    for i in range(n):
        if A[i] > mid:
            count += math.ceil(A[i]//mid)

    if count <= k:
        r = mid
    else:
        l = mid+1



print(l)

### FIXED CODE ###

import math

n, k = map(int, input().split())
A = list(map(int, input().split()))

l = 1
r = 10**9+1

while l < r:
    mid = (l+r)//2
    count = 0
    for i in range(n):
        if A[i] > mid:
            count += math.ceil(A[i]//mid)

    if count <= k:
        r = mid
    else:
        l = mid+1


print(l)
import itertools

def sieve(n):
    is_prime = [True for _ in range(n)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return table

prime = sieve(5*10**4)
acu = [0] * ((5*10**4)//2+1)
for i in range(1,(5*10**4)//2+1):
    k = (i-1) * 2 +1
    if k in prime and (k+1)//2 in prime:
        acu[i] = acu[i-1] + 1
    else:
        acu[i] = acu[i-1]

q = int(input())

for i in range(q):
    l,r = map(int,input().split())
    li = (l-1) // 2
    ri = (r-1) // 2
    print(acu[ri+1]-acu[li])

### FIXED CODE ###

from itertools import accumulate
# エラトステネスの篩
# is_prime := 1~nが素数か否か
# table := 2~nのうち素数
def sieve(n):
    is_prime = [True for _ in range(n)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table


Q = int(input())
L = [0]*Q
R = [0]*Q

for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

max_R = max(R)
is_prime, table = sieve(max_R)

check = [0]*(max_R + 1)
for i in range(0, max_R + 1):
    if (i % 2 == 1):
        if (is_prime[i-1] and is_prime[(i+1)//2-1]):
            check[i] = 1

# 累積和
check = [0] + check
check = list(accumulate(check))

for i in range(Q):
    print(check[R[i] + 1] - check[L[i]])
a,op,b=map(str,input().split())
while op!='?':
 if op=='+':
   print(int(a)+int(b))
 elif op=='-':
   print(int(a)-int(b))
 elif op=='*':
   printf(int(a)*int(b))
 elif op=='/':
   printf(int(a)//int(b))
 a,op,b=map(str,input().split())



### FIXED CODE ###

while True:
 a,op,b=map(str,input().split())
 if op=='+':
   print(int(a)+int(b))
 elif op=='-':
   print(int(a)-int(b))
 elif op=='*':
   print(int(a)*int(b))
 elif op=='/':
   print(int(a)//int(b))
 elif op=='?':
   break
import queue
x=int(input())
avail=list(range(100,106))
ok=[False]*(x+1)
q=queue.Queue()
for i in avail:
    ok[i]=True
    q.put(i)
while not q.empty():
    f=q.get()
    for i in range(100,106):
        if(i+f<=x and not ok[i+f]):
            ok[i+f]=True
            q.put(i+f)
print(1 if ok[i+f] else 0)

### FIXED CODE ###

import queue
x=int(input())
avail=list(range(100,106))
ok=[False]*max(x+1,106)
q=queue.Queue()
for i in avail:
    ok[i]=True
    q.put(i)
while not q.empty():
    f=q.get()
    for i in range(100,106):
        if(i+f<=x and not ok[i+f]):
            ok[i+f]=True
            q.put(i+f)
print(1 if ok[x] else 0)
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    h, w, a, b = ns()

    flg1 = h * a == w * b
    flg2 = w % a == 0 and h % b == 0
    flg3 = a == 0 or b == 0
    if not((flg1 and flg2) or flg3):
        print("No")
        exit(0)

    if b == 0:
        ans = "0" * a + "1" * (w - a)
        print(ans)
    elif a == 0:
        for _ in range(h):
            print("1" * w)
    else:
        for i in range(h // b):
            for j in range(b):
                ans = "1" * i + "0" * a + "1" * (w - a - a * i)
                print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    h, w, a, b = ns()

    for i in range(h):
        if i < b:
            print("0" * a + "1" * (w - a))
        else:
            print("1" * a + "0" * (w - a))


if __name__ == '__main__':
    main()
a,b,c,d = list(map(int,input.split( )))

if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a,b,c,d = list(map(int,input().split( )))

if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d):
    print('Yes')
else:
    print('No')
import numpy as np

N = int(input())
A = []
for i in range(N):
    A.append(input())

A = np.array(A)

for i in range(N):
    print(max(np.delete(A, [i], axis=0)))

### FIXED CODE ###

def main():
    a = int(input())
    lists= [int(input()) for _ in range(a)]
 
    temp = lists.copy()
    first = max(temp)
    temp.remove(first)
    second = max(temp)
 
    for i in range(a):
        if lists[i] == first:
            print(second)
        else:
             print(first)
 
if __name__ == '__main__' :
    main()
#import itertools
#import bisect
import math

N = int(input())
L = [i for i in range((N+1)//2+1)]
num = math.ceil(pow(2*(N-1),0.5))
    
for i in range(num,len(L)):
    if N == i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
    elif N < i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
Left = Max - N 
    
#acu = list(itertools.accumulate([i for i in range((N+1)//2+2)]))
#print(acu) 
#index = bisect.bisect_left(acu,N)
#print(index)

Left = Max - N    
#if acu[index] == N:
#    Max = acu[index-1]
#else:
#    Max = acu[index]
#Left = Max - N

for i in range(1,index+1):
    if i == Left:
        continue
    print(i)

### FIXED CODE ###

#import itertools
#import bisect
import math

N = int(input())
L = [i for i in range((N+2)//2+2)]
num = math.floor(pow(2*(N-1),0.5))
    
for i in range(num,len(L)):
    if N == i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
    elif N < i*(i+1)//2:
        index = i
        Max = i*(i+1)//2
        break
Left = Max - N 
#print(num,Left,Max,index,L)
#acu = list(itertools.accumulate([i for i in range((N+1)//2+2)]))
#print(acu) 
#index = bisect.bisect_left(acu,N)
#print(index)
 
#if acu[index] == N:
#    Max = acu[index-1]
#else:
#    Max = acu[index]
#Left = Max - N

for i in range(1,index+1):
    if i == Left:
        continue
    print(i)
(h,n),*t=[list(map(int,o.split()))for o in open(0)]
d=[0]*-~h
for i in range(1,h+1):d[i]=min(d[i-a]+b for a,b in t)
print(d[h])

### FIXED CODE ###

def chmin(dp, i, *x):
  dp[i] = min(dp[i], *x)
INF = float("inf")

# dp[i] := min 消耗する魔力 to H -= i
h, n = map(int, input().split())
dp = [0] + [INF]*h
for _ in [None]*n:
  a, b = map(int, input().split())
  for j in range(h + 1):
    chmin(dp, min(j + a, h), dp[j] + b)
print(dp[h])
n = int(input().split())
flag = False
for i in range(1, 10):
	for j in range(1, 10):
		if i*j == n:
        flag = True
if flag is True:
    print("Yes")
else:
	print("No")

### FIXED CODE ###

n = int(input())
flag = False
for i in range(1, 10):
	for j in range(1, 10):
		if i*j == n:
			flag = True
if flag is True:
	print("Yes")
else:
	print("No")