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

X, Y, Z, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

C.sort(reverse=True)
tmp = []
ans = []

for i in range(X):
	for j in range(Y):
		tmp.append(A[i]+B[j])

tmp.sort(reverse=True)
del tmp[min(K, X*Y):]

for i in range(len(tmp)):
	for j in range(min(Z, K)):
		ans.append(tmp[i]+C[j])

ans.sort(reverse=True)

for i in range(min(K, X*Y*Z)):
	print(ans[i])


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

C.sort(reverse=True)
tmp = []
ans = []

for i in range(X):
	for j in range(Y):
		tmp.append(A[i]+B[j])

tmp.sort(reverse=True)
del tmp[min(K, X*Y):]

for i in range(len(tmp)):
	for j in range(min(Z, K)):
		ans.append(tmp[i]+C[j])

ans.sort(reverse=True)

for i in range(min(K, X*Y*Z)):
	print(ans[i])
### BUGGY CODE ###


n = int(input())
y = list(map(int, input().split(" ")))
s = 1
for i in y:
    s *= i
if s>10**18:
    print(-1)
else:
    print(s)


### FIXED CODE ###


n = int(input())
y = list(map(int, input().split(" ")))
s = 1
hoge = False
for i in y:
    if i ==0:
        print(0)
        hoge = True

def f():
    s = 1
    for i in y:
        s *= i
        if s>10**18:
            print(-1)
            return
    print(s)
if not hoge:
    f()
### BUGGY CODE ###

n,m=map(int,input().split())
oya=[set() for i in range(n)]
ko=[set() for i in range(n)]
rank=[0]*n
for i in range(n+m-1):
    a,b=map(int,input().split())
    ko[a-1].add(b-1)
    oya[b-1].add(a-1)
for s in range(n):
    if not oya[s]:break
q={s}
ans=[0]*n
while q:
    now=q.pop()
    for i in ko[now]:
        if oya[now]:continue
        oya[i].remove(now)
        if not oya[i]:
            ans[i]=now+1
            q|=ko[now]
for i in ans:print(i)

### FIXED CODE ###

n,m=map(int,input().split())
oya=[set() for i in range(n)]
ko=[set() for i in range(n)]
rank=[0]*n
for i in range(n+m-1):
    a,b=map(int,input().split())
    ko[a-1].add(b-1)
    oya[b-1].add(a-1)
for s in range(n):
    if not oya[s]:break
q=[[s,ko[s]]]
ans=[0]*n
while q:
    now,nex=q.pop()
    for i in nex:
        oya[i].remove(now)
        if not oya[i]:
            ans[i]=now+1
            q.append([i,ko[i]])
for i in ans:print(i)
### BUGGY CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

n = N
while True:
    if sum(A[:n]) <= K:
        break
    n -= 1

m = M
max_num = 0
for n in range(n + 1):
    #print(n, m)
    if sum(A[:n]) > K:
        break
    while True:
        #print(n, m)
        if sum(A[:n]) + sum(B[:m]) <= K:
            max_num = max(max_num, n+m)
            break
        m -= 1
# print(cost)
print(max_num)


### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ma = [0] * (N + 1)
mb = [0]*(M+1)


for i in range(N):
    ma[i + 1] = ma[i] + A[i]

for i in range(M):
    mb[i + 1] = mb[i] + B[i]

j = M
max_num = 0

for i in range(N+1):
    if ma[i] > K:
        break
    while ma[i] + mb[j] > K:
        j -= 1
    max_num = max(max_num, i + j)
print(max_num)
### BUGGY CODE ###

n = int(input())
ans = 0
for i in range(n):
    ans += i
print(ans)


### FIXED CODE ###

n = int(input())
print((n*(n-1))//2)
### BUGGY CODE ###

mtch = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6} 

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

dp = [["-" for j in range(N + 1)] for i in range(N + 1)]
dp[0][0] = ""

for i in range(N + 1):
    for j in range(N + 1):
        for a in A:
            if dp[i][j] != "-" and j + mtch[a] <= N:
                added = dp[i][j] + str(a)
                if dp[i + 1][j + mtch[a]] < added:
                    dp[i + 1][j + mtch[a]] = added

for i in range(N, -1, -1):
    if dp[i][N] != "-":
        print(dp[i][N])
        break

### FIXED CODE ###

match = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

dp = [-1 for i in range(N + 1)]
dp[0] = 0
for i in range(N + 1):
    for a in A:
        if dp[i] >= 0 and i + match[a] <= N:
            dp[i + match[a]] = max(dp[i] + 1, dp[i + match[a]])

ans = ""
while N > 0:
    for a in A:
        if N - match[a] >= 0 and dp[N - match[a]] == dp[N] - 1:
            ans += str(a)
            N -= match[a]
            break

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

import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


H, W = list(map(int, sys.stdin.buffer.readline().split()))
A = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(H)]
B = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(H)]

grid = [[0] * W for _ in range(H)]
for h, w in itertools.product(range(H), range(W)):
    grid[h][w] = A[h][w] - B[h][w]

# 符号をどっちにするか選べる
dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0] = {grid[0][0], -grid[0][0]}
for h, w in itertools.product(range(H), range(W)):
    if h - 1 >= 0:
        for c in dp[h - 1][w]:
            dp[h][w].add(c + grid[h][w])
            dp[h][w].add(c - grid[h][w])
    if w - 1 >= 0:
        for c in dp[h][w - 1]:
            dp[h][w].add(c + grid[h][w])
            dp[h][w].add(c - grid[h][w])

ans = INF
for s in dp[-1][-1]:
    ans = min(ans, abs(s))

print(ans)


### FIXED CODE ###

import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


H, W = list(map(int, sys.stdin.buffer.readline().split()))
A = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(H)]
B = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(H)]

grid = [[0] * W for _ in range(H)]
for h, w in itertools.product(range(H), range(W)):
    grid[h][w] = A[h][w] - B[h][w]

# 符号をどっちにするか選べる
dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0] = {grid[0][0] % 800, -(grid[0][0]) % 800}
for h, w in itertools.product(range(H), range(W)):
    g = grid[h][w]
    s = dp[h][w]
    if h - 1 >= 0:
        for c in dp[h - 1][w]:
            s.add((c + g) % 800)
            s.add((c - g) % 800)
    if w - 1 >= 0:
        for c in dp[h][w - 1]:
            s.add((c + g) % 800)
            s.add((c - g) % 800)
# print(grid)
# print(dp)
ans = INF
for s in dp[-1][-1]:
    ans = min(ans, s)
    ans = min(ans, (-s) % 800)
print(ans)
### BUGGY CODE ###

mod = pow(10,9)+7
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]+[mod]
DP = [1]
for i in range(1,N+1):
    if i==A[0]:
        DP.append(0)
        A = A[1:]
    else:
        a = DP[i-1]
        b = DP[i-2] if i>1 else 0
        DP.append(a+b)
print(DP[N]%mod)


### FIXED CODE ###

import bisect
def f(x,a):
  global M
  b = bisect.bisect_left(a,x)
  if x==a[min(b,M)]:
    return True
  else:
    return False
MOD = 10**9+7
N,M = map(int,input().split())
a = [-1]+[int(input()) for _ in range(M)]
a.sort()
x = 0
y = 1
for i in range(N):
  if f(i,a) and f(i+1,a):
    print(0)
    exit()
  elif f(i+1,a):
    z = 0
  else:
    z = x + y
  x = y
  y = z
print(z%MOD)
### BUGGY CODE ###

Q=int(input())
for q in range(Q):
    l,r=map(int,input().split())
    count=0
    for N in range(l,r+1,2):
        if all([N%i for i in range(2,int(N**.5)+1)]) and all([((N+1)/2)%i for i in range(2,int(((N+1)/2)**.5)+1)]) and N!=1:
            count+=1
    print(count)

### FIXED CODE ###

N=10**5
prime=[1]*(N+1)
prime[0]=prime[1]=0
for i in range(2,int(N**.5)+1):
    if not prime[i]:
        continue
    for j in range(i*2,N+1,i):
        prime[j]=0

check=[0]*(N+1)
for n in range(N+1):
    if n%2==1 and prime[n] and prime[(n+1)//2]:
        check[n]=1

accumulate=[0]*(N+1)
for n in range(1,N+1):
    accumulate[n]=accumulate[n-1]+check[n]

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

N = int(input())
A = [int(input()) for _ in range(N)]


for i in range(N):
    temp_1 = A[:i]
    temp_2 = A[i + 1:]
    print(max(temp_1 + temp_2))
  

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
sort_A = sorted(A)
max_A = sort_A[-1]

for i in A:
    if max_A != i:
        print(max_A)
    else:
        print(sort_A[-2])
### BUGGY CODE ###

n=int(input())
s=list(input())

ans=[]
for i in range(n+1):
  ans.append(s[:i].count('#')+s[i:].count('.'))
print(min(ans))

### FIXED CODE ###

n = int(input())
s = input()


cost = 0
bc = 0
for it in s:
    if it =="#":
        bc += 1
    elif bc > 0:
        cost += 1
        bc -= 1

print(cost)
### BUGGY CODE ###

n = int(input())
word = [input() for _ in range(n)]
count = 0

for i in range(n-1):
    for j in range(i+1,n):
        a = sorted(word[i])
        b = sorted(word[j])
        if a == b:
            count += 1

print(count)


### FIXED CODE ###

import itertools,math
n = int(input())
word = [input() for _ in range(n)]
count = 0

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(n):
    word[i] = sorted(word[i])

new_word = list(sorted(word))

x = 1

for i in range(n-1):
    if new_word[i] == new_word[i+1]:
        x += 1
    elif x >= 2:
        count += combinations_count(x,2)
        x = 1
if x >= 2:
    count +=  combinations_count(x,2)

print(count)
### BUGGY CODE ###

N = int(input())
S = [int(c) for c in input()]

answer_set = set()
for i_1 in range(N-2):
    for i_2 in range(i_1+1, N-1):
        for i_3 in range(i_2+1, N):
            password = (S[i_1], S[i_2], S[i_3])
            answer_set.add(password)
            
answer = len(answer_set)
print(answer)

### FIXED CODE ###

def I(): return int(input())
N = I()
S = input()
ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0])==-1:
        continue
    S1 = S[S.find(num[0])+1:]
    if S1.find(num[1])==-1:
        continue
    S2 = S1[S1.find(num[1])+1:]
    if S2.find(num[2])==-1:
        continue
    ans += 1
print(ans)
### BUGGY CODE ###

from decimal import *
getcontext().prec = 10000
a, b, c = [Decimal(int(i)) for i in input().split()]
if c.sqrt() - a.sqrt() - b.sqrt() < Decimal(-100).exp():
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a, b, c = [int(i) for i in input().split()]
if a + b >= c:
    print("No")
else:
    if 4 * a * b < (c - a - b)** 2:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

n, x, m = map(int, input().split())
l = [x]
a = x
loopsum = 0
loopnum = 0


for i in range(n - 1):
    a = a**2%m
    if a not in l:
        l.append(a)
    else:
        pos = l.index(a)
        loopnum = len(l[pos:])
        loopsum = sum(l[pos:])
        break

if loopnum > 0:
    rest = (n - len(l))%loopnum
    times = (n - len(l))//loopnum
    ans = sum(l) + loopsum*times
    for i in range(rest):
        ans += l[pos + i]
else:
    ans = sum(l)

print(ans)

### FIXED CODE ###

n, x, m = map(int, input().split())
l = [x]
a = x
loopsum = 0
loopnum = 0


for i in range(n - 1):
    a = a**2%m
    if a not in l:
        l.append(a)
    else:
        pos = l.index(a)
        loopnum = len(l[pos:])
        loopsum = sum(l[pos:])
        break

if loopnum > 0:
    rest = (n - len(l))%loopnum
    times = (n - len(l))//loopnum
    ans = sum(l) + loopsum*times
    for i in range(rest):
        ans += l[pos + i]
else:
    ans = sum(l)

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

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

mod = 1000000007

f = [] # 素因数分解(指数部のみ)

for p in range(2, M): # 素因数分解
    e = 0
    while M%p == 0:
        e += 1
        M /= p
    
    if e>0:
        f.append(e)
    
    if M == 1:
        break

def pw(a, e):
    if e == 0:
        return 1
    p = pw(a, e//2)
    if e%2 == 1:
        return p * p % mod * a % mod
    else:
        return p * p % mod; 

# fact, inv の計算
fact = [1]
inv = [1]
for k in range(1, 100064):
    fact.append(fact[k-1] * k % mod)
    inv.append(pw(fact[k], mod-2))

def combine(n, k):
    return fact[n] * inv[k] % mod * inv[n-k] % mod

ans = 1
for e in f:
    ans *= combine(e+N-1, e) # N_H_e (重複組合せ)
    ans %= mod

print(ans)


### FIXED CODE ###

from collections import Counter

mod = 1000000007

# nの素因数分解

def prime(n):
    d = Counter()
    i = 2
    while i*i <= n:
        while n%i == 0:
            n //= i
            d[i] += 1
        i += 1
    if n > 1:
        d[n] += 1
    return d

# xのn乗を計算する
def mod_pow(x, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        half_x = mod_pow(x, n // 2)
        return half_x * half_x % mod
    else:
        return x * mod_pow(x, n-1) % mod

fact = [1] * 100100
inv = [1] * 100100
for k in range(1, 100100):
    fact[k] = fact[k-1] * k % mod
    inv[k] = mod_pow(fact[k], mod-2)

def nCr(n, r):
    return fact[n] * inv[r] % mod * inv[n-r] % mod

def solve():
    N, M = map(int, input().split())
    p = prime(M)
    s = 1
    for i in p.values():
        s *= nCr(i + N - 1, N - 1)
        s %= mod
    print(s)

solve()
### BUGGY CODE ###

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

for i in range(n):
    if (i+1) %2 == n % 2:
        b.insert(0, a[i])
    else:
        b.append(a[i])
print(*b)

### FIXED CODE ###

from collections import deque

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

b = deque()

for i in range(n):
    if (i+1) %2 == n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
ans = list(b)
print(*ans)
### BUGGY CODE ###

N = int(input())

for i in range(1,N+1):
  ans = 0
  if i < 6:
    print(0)
  else:
    total = 11
    if i > total/2:
      for a in range(2,N+1):
        for b in range(2,N+1):
          for c in range(2,N+1):
            total = a**2 + b**2 +c**2
            if total == 2*i:
              if max(a,b,c) < a+b+c-max(a,b,c):
                if len({a,b,c}) == 1:
                  ans = 1
                  continue
                elif len({a,b,c}) == 2:
                  ans = 3
                  continue
                else:
                  ans = 6
                  continue
    else:
      ans = 0

              #print(a,b,c)
    print(ans)



### FIXED CODE ###

import numpy as np

N = int(input())

#print(1e+5)
ans = np.zeros(int(1e+5),dtype = int)
for x in range(1,int(N**0.5+1)):
  for y in range(x,int((N-x**2)**0.5+1)):
    for z in range(y,int((N-x**2-y**2)**0.5+1)):
      n = x**2 + y**2 + z**2 +x*y+y*z+z*x
      num = len({x,y,z})
      if num == 1:
        ans[n] += 1
      elif num == 2:
        ans[n] += 3
      elif num == 3:
        ans[n] += 6

for i in range(1,N+1):
  print(ans[i])
### BUGGY CODE ###

n,q = map(int, input().split())
s = input()
a = [0]*n
for i in range(n):
  a[i] = s[:i+1].count('AC')
for i in range(q):
  l,r = map(int, input().split())
  print(a[r-1]-a[l-1])

### FIXED CODE ###

n,q = map(int, input().split())
s = input()
a = [0]*n
for i in range(n):
  if s[i-1]=="A" and s[i]=="C":
    a[i] = a[i-1]+1
  else:
    a[i] = a[i-1]
for i in range(q):
  l,r = map(int, input().split())
  print(a[r-1]-a[l-1])
### BUGGY CODE ###

from fractions import gcd
n = int(input())
A = list(map(int, input().split()))

def gcd_list(l):
    if len(l) == 0:
        l.append(0)
    res = l[0]
    for i in range(len(l)):
        res = gcd(res, l[i])
    return res

m = []
for i in range(n):
    left = gcd_list(A[:i])
    if i == n-1:
        right = 0
    else:
        right = gcd_list(A[i+1:])
    m.append(gcd(left, right))

print(max(m))

### FIXED CODE ###

from fractions import gcd
n = int(input())
A = list(map(int, input().split()))

m = []
left = [0]
right = [0]
for i in range(n):
    left.append(gcd(left[i], A[i]))
    right.append(gcd(right[i], A[n-i-1]))
    

for i in range(n):
    m.append(gcd(left[i], right[n-i-1]))
    
print(max(m))
### BUGGY CODE ###

import bisect
from collections import defaultdict as dd
n, m, q = map(int, input().split())
Tr = []
L2Rs = dd(lambda: [])
for i in range(m):
  l, r = map(int, input().split())
  Tr.append([l, r])
  L2Rs[l] += [r]
Tr.sort(key=lambda x: x[0])
for i in L2Rs.keys():
  L2Rs[i] = sorted(L2Rs[i])
L = sorted(L2Rs.keys())

Sc = []
for i in range(q):
  Sc.append(list(map(int, input().split())))
#Sc.sort(key=lambda x: x[0])
#print(Sc)

for i in range(q):
  left, right = Sc[i]
  l_ok_index = bisect.bisect_left(L, left)
  counter = 0
  for j in range(l_ok_index, len(L)):
    #print(j, L2Rs[j], left, right)
    r_ok = bisect.bisect_right(L2Rs[L[j]], right)
    #print(r_ok)
    counter += r_ok
  print(counter)

### FIXED CODE ###

n, m, q = map(int, input().split())
Arr = []
for i in range(n+1):
  Arr.append([0] * (n+1))
for i in range(m):
  l, r = map(int, input().split())
  Arr[l][r] += 1
#print(Arr)

B = []
for i in range(n+1):
  B_line = [0]
  for j in range(1, n+1):
    B_line.append(B_line[-1] + Arr[i][j])
  B.append(B_line)
#print(B)
  
for x in range(q):
  left, right = map(int, input().split())
  train_num = 0
  for i in range(left, right+1):
    train_num += B[i][right] - B[i][left-1]
  print(train_num)
### BUGGY CODE ###

n=int(input())
li = list(map(int,input().split()))
ans=[]
a=""
for i in range(1,n+1):
  ans.append(li.index(i)+1)
print(' '.join(map(str, ans)))


### FIXED CODE ###

n=int(input())
li = list(map(int,input().split()))
ans=[0]*n
a=""
for (i,x) in zip(range(0,n), li):
  ans[x-1]=i+1
print(' '.join(map(str, ans)))
### BUGGY CODE ###

import math

K = int(input())


def gcd3(a, b, c):
    d = math.gcd(a, b)
    e = math.gcd(d, c)
    return e


ans = 0
for x in range(1, K + 1, 1):
    for y in range(1, K + 1, 1):
        for z in range(1, K + 1, 1):
            ans = ans + gcd3(x, y, z)

print(ans)


### FIXED CODE ###

import math

K = int(input())

ans = 0
for x in range(1, K + 1, 1):
    for y in range(1, K + 1, 1):
        ans = ans + sum(list(map(lambda z: math.gcd(math.gcd(x, y), z), range(1, K+1, 1))))

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

def sosucheck(num):
    if num == 1:return False
    flag = True
    for i in range(1, int(num **(1/2))+1):
        if flag:
            flag = False
        else:
            if num % i == 0:
                return False
    return True
Q = int(input())
lis = []
for _ in range(Q):
    l, r = map(int, input().split())
    lis.append((l, r))
for (l, r) in lis:
    count = 0
    for num in range(l,r+1,2):
        if sosucheck(num):
            if sosucheck((num+1)/2):
                count += 1
    print(count)

### FIXED CODE ###

import copy
Q = int(input())
lis = []
maximam = 1
for _ in range(Q):
    l, r = map(int, input().split())
    lis.append((l, r))
    maximam = max(maximam, r)
flag_lis = [1] * (maximam+1)
flag_lis[0] = 0
flag_lis[1] = 0
for i in range(2, int((maximam-1)/2)+1):
    if flag_lis[i] != 0:
        for j in range(2*i,maximam+1,i):
            flag_lis[j] = 0
fin_lis = [0]*(maximam+1)
count = 0
for i in range(3, maximam+1, 2):
    if flag_lis[i] == 1 and flag_lis[int((i+1)/2)] == 1:
        count += 1
    fin_lis[i] = count
for (l, r) in lis:
    if l == 1:
        print(fin_lis[r] - 0)
    else:
        print(fin_lis[r] - fin_lis[l-2])
### BUGGY CODE ###

import heapq

n = int(input())
distance = [[float('inf')] * n for _ in range(n)]
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    distance[a - 1][b - 1] = c
    distance[b - 1][a - 1] = c
q, k = map(int, input().split())
k -= 1
queries = []
for _ in range(q):
    x, y = map(int, input().split())
    queries.append((x - 1, y - 1))

d = [float('inf')] * (n + 1)
d[k] = 0
queue = [(0, k)]
while queue:
    cost, current = heapq.heappop(queue)
    for nxt in range(n):
        if cost + distance[current][nxt] < d[nxt]:
            d[nxt] = cost + distance[current][nxt]
            heapq.heappush(queue, (d[nxt], nxt))

for x, y in queries:
    print(d[x] + d[y])

### FIXED CODE ###

import heapq, collections

n = int(input())
distance = collections.defaultdict(dict)
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    distance[a - 1][b - 1] = c
    distance[b - 1][a - 1] = c
q, k = map(int, input().split())
k -= 1
queries = []
for _ in range(q):
    x, y = map(int, input().split())
    queries.append((x - 1, y - 1))

d = [float('inf')] * (n + 1)
d[k] = 0
queue = [(0, k)]
while queue:
    cost, current = heapq.heappop(queue)
    for nxt in distance[current]:
        if cost + distance[current][nxt] < d[nxt]:
            d[nxt] = cost + distance[current][nxt]
            heapq.heappush(queue, (d[nxt], nxt))

for x, y in queries:
    print(d[x] + d[y])
### BUGGY CODE ###

def main():
    from fractions import gcd

    MOD = 10 ** 9 + 7

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

    tmp = 1
    for a in A:
        tmp *= a // gcd(tmp, a)

    ans = 0
    for a in A:
        ans += (tmp // a)
    ans %= MOD

    print (ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    from fractions import gcd

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

    MOD = 10 ** 9 + 7

    tmp = 1
    for a in A:
        tmp *= a // gcd(tmp, a)

    ans = 0
    for a in A:
        ans += tmp // a
    ans %= MOD

    print (ans)

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

# -*- coding: utf-8 -*-
import math

MOD = 10 ** 9 + 7

def main():
    N = int(input())
    S = input().strip()

    if S[0] == 'W' or S[-1] == 'W':
        print(0)
        return

    Sp = ''
    Dc = True
    Lcnt = 0
    Rcnt = 0
    Pattern = 1
    for Sc in S:
        if Sc == Sp:
            Dc = not Dc
        Sp = Sc

        if not Dc:
            Pattern *= Lcnt - Rcnt

        Lcnt += 1 if Dc else 0
        Rcnt += 1 if not Dc else 0

    if Lcnt == Rcnt:
        Pattern *= math.factorial(N)
        Pattern = Pattern % MOD
        print(Pattern)
    else:
        print(0)

if __name__ == "__main__":
    main()


### FIXED CODE ###

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

MOD = 10 ** 9 + 7

N = int(input())
S = list(map(lambda x: int(x == "W"),input()))
if S[0] or S[-1]:
    print(0)
    exit(0)

Dc = 1
LRsub = 1
Pattern = 1
Sp = S[0]

for i in range(1,N*2):
    Sc = S[i]
    Dc = Dc if Sc != Sp else -Dc
    Sp = Sc
    if Dc < 0:
        Pattern = (Pattern * LRsub) % MOD
    LRsub += Dc

if LRsub == 0:
    for i in range(2,N+1):
        Pattern = (Pattern * i) % MOD
    print(Pattern)
else:
    print(0)
### BUGGY CODE ###

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

for i in range(1,N+1):
    print(A.count(i))

### FIXED CODE ###

ans=[0]*int(input())
N=list(map(int,input().split()))

for i in N:
    ans[i-1]+=1
print(*ans)
### BUGGY CODE ###


s = int(input())
temp = []
temp.append(s)
former = s
idx = 1

while True:
    idx += 1
    if former % 2 == 0:
        later = former / 2
    else:
        later = former * 3 + 1

    if later in temp:
        print(idx)
        break


### FIXED CODE ###


s = int(input())
temp = []
temp.append(s)
former = s
idx = 1

while True:
    idx += 1
    later = former / 2 if former % 2 == 0 else former * 3 + 1

    if later in temp:
        print(idx)
        break
    temp.append(later)
    former = later
### BUGGY CODE ###

A, B, K = map(int, input().split())

for i in range(K):
    if A > 0:
        A -= 1
    else:
        B -= 1

print(A, B)

### FIXED CODE ###

A, B, K = map(int, input().split())
 
if A >= K:
    print(A-K,B)
elif A+B-K >= 0:
    print(0, A+B-K)
else:
    print("0 0")
### BUGGY CODE ###

#!/usr/bin/python3
# abc061_c
"""
Big Array
"""

def answer():
    """
    答えを出力する関数
    """
    l = []
    N, K = map(int, input().split())

    for _ in range(N):
        a, b = map(int, input().split())
        l += [a] * b

    # 小さい順にソートして、K-1番目の要素を出力
    l.sort()
    print(l[K-1])


def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/python3
# abc061_c
"""
Big Array
"""

def answer():
    """
    答えを出力する関数
    """
    l = []
    N, K = map(int, input().split())
    counter = 0

    for _ in range(N):
        l.append(list(map(int, input().split())))

    l.sort()
    for v in l:
        counter += v[1]
        if counter >= K:
            print(v[0])
            break

def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()