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

def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    anslis = []
    for i in range(n):
        junban = inlis.index(i+1) + 1
        anslis.append(junban)
    print(*anslis)
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    anslis = [0] * n
    for i in range(n):
        num = inlis[i]
        anslis[num-1] = i+1
    print(*anslis)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from collections import deque


# (sx, sy) から (gx, gy) への最短距離を求める
# 辿り着けないと INF
def bfs():
    # すべての点を INF で初期化
    d = [[float("inf")] * m for i in range(n)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]



    # スタート地点をキューに入れ、その点の距離を0にする
    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 取り出してきた状態がゴールなら探索をやめる
        if p[0] == gx and p[1] == gy:
            break
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[gx][gy]


n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]
ans = 0
for sx in range(n):
    for sy in range(m):
        for gx in range(n):
            for gy in range(m):
                if maze[sx][sy] == '.' and maze[gx][gy] == '.' and not (sx == gx and sy == gy):
                    if bfs() != float('inf'):
                        ans = max(ans,bfs())
print(ans)

### FIXED CODE ###

from collections import deque


# (sx, sy) から (gx, gy) への最短距離を求める
# 辿り着けないと INF
def bfs():
    # すべての点を -INF で初期化
    d = [[-float("inf")] * m for i in range(n)]

    # 移動4方向のベクトル
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]



    # スタート地点をキューに入れ、その点の距離を0にする
    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    # キューが空になるまでループ
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # # 取り出してきた状態がゴールなら探索をやめる
        # if p[0] == gx and p[1] == gy:
        #     break
        # 移動4方向をループ
        for i in range(4):
            # 移動した後の点を (nx, ny) とする
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            # 移動が可能かの判定とすでに訪れたことがあるかの判定
            # d[nx][ny] != INF なら訪れたことがある
            if 0 <= nx < n and 0 <= ny < m and maze[nx][ny] != "#" and d[nx][ny] == -float("inf"):
                # 移動できるならキューに入れ、その点の距離を p からの距離 +1 で確定する
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    #return d[gx]
    a = 0
    for i in range(n):
        for j in range(m):
            a = max(d[i][j],a)
    return a

    #return max(d)


n, m = map(int, input().split())
maze = [list(input()) for i in range(n)]
ans = 0
for sx in range(n):
    for sy in range(m):
        if maze[sx][sy] == '.':
            ans = max(ans, bfs())
        # for gx in range(n):
        #     for gy in range(m):
        #         if maze[sx][sy] == '.' and maze[gx][gy] == '.' and not (sx == gx and sy == gy):
        #             if bfs() != float('inf'):
        #                 ans = max(ans,bfs())
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
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()))

v = []

for i in range(x):
    for j in range(y):
        for l in range(z):
            v.append(a[i]+b[j]+c[l])


v = sorted(v, reverse=True)

for vv in v[0:k]:
    print(vv)


### FIXED CODE ###

# -*- coding: utf-8 -*-
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()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


d = [e1+e2 for e1 in a for e2 in b]
d.sort(reverse=True)
d = d[:k]

e = [e1+e2 for e1 in d for e2 in c]
e.sort(reverse=True)


for i in range(k):
    print(e[i])
### BUGGY CODE ###

from collections import deque
s = input()
q = int(input())
array = [list(map(str, input().split())) for i in range(q)]
d = deque(s)
for i in range(q):
    if array[i][0] == "1":
        d.reverse()
    elif array[i][1] == "1":
        d.appendleft(array[i][2])
    elif array[i][1] == "2":
        d.append(array[i][2])
d_str = "".join(list(d))
print(d_str)

### FIXED CODE ###

from collections import deque
s = input()
q = int(input())
array = [list(map(str, input().split())) for i in range(q)]
#print(array)
d = deque(s)
reverse = 1
for i in range(q):
    if array[i][0] == "1":
        reverse *= -1
    elif (array[i][1] == "1") and (reverse == 1):
        d.appendleft(array[i][2])
    elif (array[i][1] == "1") and (reverse == -1):
        d.append(array[i][2])
    elif (array[i][1] == "2") and (reverse == 1):
        d.append(array[i][2])
    elif (array[i][1] == "2") and (reverse == -1):
        d.appendleft(array[i][2])

if reverse == -1:
    d.reverse()

d_str = "".join(list(d))
print(d_str)
### BUGGY CODE ###

import heapq

def dijkstra(ad_lst, n, s, t):
    inf = float('inf')
    costs = [inf for i in range(n+1)]
    costs[s] = 0
    Q = []
    heapq.heappush(Q, [costs[s], s])

    while(Q != []):
        c, u = heapq.heappop(Q)
        for v, c in ad_lst[u]:
            if costs[u] + c < costs[v]:
                alt = costs[u] + c
                heapq.heappush(Q, [alt, v])
                costs[v] = alt

    return costs

n,m,s,t, = map(int, input().split())

route_y = {i: [] for i in range(n+1)}
route_s = {i: [] for i in range(n+1)}
for i in range(m):
    u, v, a, b = map(int, input().split())
    route_y[u].append([v,a])
    route_y[v].append([u,a])
    route_s[u].append([v,b])
    route_s[v].append([u,b])

cost_y = dijkstra(route_y, n, s, t)
cost_s = dijkstra(route_s, n, t, s)
cost_ys = [y+s for y,s in zip(cost_y, cost_s)]

inf = float('inf')
result = [inf for _ in range(n+1)]
min_cost = result[-1]
for i in range(n, 0, -1):
    if min_cost > cost_ys[i]:
        min_cost = cost_ys[i]
    result[i] = min_cost
yen = 10**15
for i in range(1, n+1):
    print(yen - result[i])


### FIXED CODE ###

import heapq
from itertools import accumulate
inf = float('inf')

def dijkstra(ad_lst, n, s):
    costs = [inf for i in range(n+1)]
    costs[s], Q = 0, []
    heapq.heappush(Q, [costs[s], s])

    while(Q != []):
        c, u = heapq.heappop(Q)
        for v, c in ad_lst[u].items():
            if costs[u] + c < costs[v]:
                heapq.heappush(Q, [costs[u] + c, v])
                costs[v] = costs[u] + c

    return costs

n,m,s,t, = map(int, input().split())

route_y = {i: {} for i in range(n+1)}
route_s = {i: {} for i in range(n+1)}
for i in range(m):
    u, v, a, b = map(int, input().split())
    route_y[u][v] = a
    route_y[v][u] = a
    route_s[u][v] = b
    route_s[v][u] = b

cost_y = dijkstra(route_y, n, s)
cost_s = dijkstra(route_s, n, t)
result = list(accumulate([y+s for y,s in zip(cost_y, cost_s)][::-1], min))
yen = 10**15
[print(yen-result[i]) for i in range(n-1, -1, -1)]
### BUGGY CODE ###

import sys
import bisect
input=sys.stdin.readline

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

a.sort()

for _ in range(m):
    val=a.pop()//2
    bisect.insort(a, val)

print(sum(a))


### FIXED CODE ###

import sys
import heapq
import numpy as np
input=sys.stdin.readline

n,m=map(int, input().split())
a=list(map(int, input().split()))
h=[]
for val in a:
    heapq.heappush(h, -val)

for _ in range(m):
    val=(-heapq.heappop(h))//2
    heapq.heappush(h, -val)

print(-sum(h))
### BUGGY CODE ###

from statistics import median
q0=int(input())
ind=0
a=[]
b=[]
for iii in range(q0):
  q=[int(_) for _ in input().split()]
  lenq=len(q)
  if lenq==1:
    meda=median(a)
    ind=sum([abs(_a-meda) for _a in a])+sum(b)
    i=1
    while sum([abs(_a-i-meda) for _a in a])+sum(b)==ind:
      i+=1
    print(int(meda-i+1),int(ind))
  elif lenq==3:
    a.append(q[1])
    b.append(q[2])

  
    
    


### FIXED CODE ###

import heapq as h
q_num=int(input())
bsum=0
high=[]
low=[]
asum=0
for iii in range(q_num):
  q=[int(_) for _ in input().split()]
  if q[0]==1:
    bsum+=q[2]
    if len(low)==0:
      h.heappush(low,-q[1])
    else:
      asum+=abs(q[1]+low[0])
      if -low[0]>=q[1]:
        h.heappush(low,-q[1])
      else:
        h.heappush(high,q[1])
      
    if len(low)>=len(high)+2:
      ltoh=h.heappop(low)
      h.heappush(high, -ltoh)
    elif len(high)>=len(low)+1:
      ltoh=h.heappop(high)
      asum+=-low[0]-ltoh
      h.heappush(low, -ltoh)
  else:
    print(-low[0],asum+bsum)
### BUGGY CODE ###

from sys import exit

n = int(input())
print(0, flush=True)
#outl = 0
in2 = input()
if in2 == "Vacant":
	exit()
print(n//2, flush=True)
#outr = n//2
in1 = input()
if in1 == "Vacant":
	exit()
#if ((n//2) % 2 == 0 and in1 != in2) or ((n//2) % 2 == 1 and in1 == in2):
	#outl = n//2
	#outr = n

#outl, outr = min(outl, outr), max(outl, outr)
outl, outr = 0, n

while True:
	#前半を見るパターン
	if (((outl+outr)//2) % 2 == 0 and in1 != in2) or ((outl+outr)//2) % 2 == 1 and in1 == in2):
		outr = (outl+outr)//2
		print((outl+outr)//2, flush=True)
		in2 = in1
		in1 = input()
		if in1 == "Vacant":
			exit()

	#後半を見るパターン
	else:
		outl = (outl+outr)//2
		print((outl+outr)//2, flush=True)
		in2 = in1
		in1 = input()
		if in1 == "Vacant":
			exit()

### FIXED CODE ###

from sys import exit

n = int(input())
print(0, flush=True)
inl = input()
inr = inl
if inl == "Vacant":
	exit()
print(n//2, flush=True)
#outr = n//2
inm = input()
if inm == "Vacant":
	exit()

outl, outr = 0, n

while True:
	#前半を見るパターン
	if (((outl+outr)//2 - outl) % 2 == 0 and inl != inm) or (((outl+outr)//2 - outl) % 2 == 1 and inl == inm):
		outr = (outl+outr)//2
		print((outl+outr)//2, flush=True)
		inr = inm
		inm = input()
		if inm == "Vacant":
			exit()

	#後半を見るパターン
	else:
		outl = (outl+outr)//2
		print((outl+outr)//2, flush=True)
		inl = inm
		inm = input()
		if inm == "Vacant":
			exit()
### BUGGY CODE ###

import sys

s = input()
t = input()

including = True
for x in t:
    if x  not in s:
        including = False
        break
if not including:
    print(-1)
    sys.exit()


x = 0
y = 0
while True:
    index = x % len(s)
    if s[index] == t[y]:
        y += 1
        if y == len(t):
            break
    x += 1

print(x + 1)

### FIXED CODE ###

import bisect

S = input().strip()
T = input().strip()

x = [[] for j in range(26)]

for i, s in enumerate(S):
    x[ord(s) - ord('a')].append(i)

sett = list(set(T))

for t in sett:
    if len(x[ord(t) - ord('a')]) == 0:
        print(-1)
        exit()

c = 0
z = 0

for t in T:
    y = bisect.bisect_left(x[ord(t) - ord('a')], c)
    if y == len(x[ord(t) - ord('a')]):
        z += 1
        c = x[ord(t) - ord('a')][0] + 1
    else:
        c = x[ord(t) - ord('a')][y] + 1

print(z * len(S) + c)
### BUGGY CODE ###

import math
from functools import reduce

K = int(input())

def gcd(a, b, c):
    return reduce(math.gcd, [a, b, c])

S = 0

tempDict = {}

for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            tempTuple = tuple([a, b, c])
            
            if  tempTuple in tempDict:
                S += tempDict[tempTuple]
            else:
                temp = gcd(a, b, c)
                tempDict[tempTuple] = temp
                S += temp

print(S)

### FIXED CODE ###

import math
import itertools

from functools import reduce

K = int(input())

def gcd(tempList):
    return reduce(math.gcd, tempList)

S = 0
tempDict = {}

for combination in itertools.combinations_with_replacement(range(1, K + 1), 3):
    if not combination[0] in tempDict:
        tempDict[combination[0]] = {}
    
    if not combination[1] in tempDict[combination[0]]:
        tempDict[combination[0]][combination[1]] = {}

    if not combination[2] in tempDict[combination[0]][combination[1]]:
        tempDict[combination[0]][combination[1]][combination[2]] = 0
        
    tempDict[combination[0]][combination[1]][combination[2]] = gcd(combination)


for n in itertools.product(range(1, K + 1), repeat=3):
    n = list(n)
    n.sort()
    
    S += tempDict[n[0]][n[1]][n[2]]

print(S)
### BUGGY CODE ###


mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

for i in range(N - 1):
	add = 0
	for j in range(1, N - i):
		add += As[i + j]
	ans += As[i] * add
print(ans % mod)


### FIXED CODE ###


mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

for i in range(N):
	add += As[i]
	add %= mod
ans = add * add % mod

for i in range(N):
	ans -= As[i] * As[i] % mod
	if (ans < 0):
		ans += mod

ans *= int((mod + 1) / 2)
ans %= mod

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

N = int(input())
print(sum([i for i in range(N)]))

### FIXED CODE ###

import math
N = int(input())
print(math.floor((N*(N-1)//2)))
### BUGGY CODE ###

a,b,k = [int(i) for i in input().split()]

for i in range(k):
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
  else:
    pass
  
print(a,b)

### FIXED CODE ###

a,b,k = [int(i) for i in input().split()]
 
if a + b <= k:
  print(0,0)
elif k >= a:
  print(0, b - (k-a))
else:
  print(a-k,b)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)


from functools import lru_cache

n = list(map(int, list(input())))
m = len(n)

@lru_cache(10**10)
def rec(keta, tight):
    if keta == m:
        if tight:
            return 1
        else:
            return 0
    tmp = float("inf")
    for i in range(10):
        if tight:
            if i == 0:
                tmp = min(tmp, rec(keta+1, True)+9-n[keta])

            elif i <= n[keta]:
                tmp = min(tmp, rec(keta+1, True)+i+10+i-1-n[keta])
            else:
                tmp = min(tmp, rec(keta+1, False)+i+i-1-n[keta])
        else:
            if i < n[keta]:
                tmp = min(tmp, rec(keta+1, True)+i+(10+i)-n[keta])
            else:
               tmp = min(tmp, rec(keta+1, False)+i+i-n[keta])
    return tmp

ans = rec(0, False)
print(ans)


### FIXED CODE ###

n = list(map(int, list(input())))
m = len(n)

DP = [[float("inf")]*2 for i in range(m+1)]
DP[0] = [0,1]

for i in range(m):
    # tight
    tmp = float("inf")
    for j in range(10):
        if j == 0:
            tmp = min(tmp, DP[i][1]+9-n[i])
        elif j <= n[i]:
            tmp = min(tmp, DP[i][1]+j+10+j-1-n[i])
        else:
            tmp = min(tmp, DP[i][0]+j+j-1-n[i])
    DP[i+1][1] = tmp

    # not tight
    tmp = float("inf")
    for j in range(10):
        if j < n[i]:
            tmp = min(tmp, DP[i][1]+j+(10+j)-n[i])
        else:
            tmp = min(tmp, DP[i][0]+j+j-n[i])
    DP[i+1][0] = tmp

print(DP[-1][0])
### BUGGY CODE ###

from heapq import heapify, heappush, heappop
from collections import defaultdict
import sys
input = sys.stdin.readline

def solve():
    N, Q = map(int, input().split())
    events = []
    for i in range(N):
        S, T, X = map(int, input().split())
        events.append((S-X-0.5, 1, X))
        events.append((T-X-0.5, 0, X))
    for i in range(Q):
        D = int(input())
        events.append((D, 2, i))

    events.sort()

    anss = [-1] * Q
    PQ = []
    isClosed = defaultdict(int)
    for tm, tp, x in events:
        if tp == 0:
            isClosed[x] = 0
        elif tp == 1:
            isClosed[x] = 1
            heappush(PQ, x)
        else:
            while PQ:
                if isClosed[PQ[0]] == 1:
                    anss[x] = PQ[0]
                    break
                heappop(PQ)

    print('\n'.join(map(str, anss)))


solve()


### FIXED CODE ###

from heapq import heapify, heappush, heappop
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
events = []
for iR in range(N):
    S, T, X = map(int, input().split())
    events.append((S-X, T-X, X))
events.sort()

iE = 0
anss = []
PQ = []
for _ in range(Q):
    D = int(input())
    while iE < N and events[iE][0] <= D:
        tmSt, tmEn, x = events[iE]
        heappush(PQ, (x, tmEn))
        iE += 1

    xMin = -1
    while PQ:
        x, tmEn = heappop(PQ)
        if tmEn > D:
            xMin = x
            heappush(PQ, (x, tmEn))
            break
    anss.append(xMin)

print('\n'.join(map(str, anss)))
### BUGGY CODE ###

import copy

s = input()

tmp = ""
count = 0
while(True):
    flag = False
    for i in range(len(s)-1):
        if(flag == True): flag = False
        elif(s[i] != s[i+1]):
            count += 2
            flag = True
        else: tmp += s[i]

    if(flag == False and len(s) != 0): tmp += s[len(s)-1]
    if(s == tmp): break

    s = copy.deepcopy(tmp)
    tmp = ""

print(count)

### FIXED CODE ###

s = input()

count_0 = 0
count_1 = 0

for i in s:
    if(i == "0"): count_0 += 1
    else: count_1 += 1

print(min([count_0, count_1])*2)
### BUGGY CODE ###

from collections import Counter
import math

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

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

[s[i].sort() for i in range(len(s))]

cnt = 0
for i in s:
    for j in s:
       if i == j:
        cnt += 1
cnt = (cnt - N)//2

# c = collections.Counter(s)
s = [' '.join(s[i]) for i in range(len(s))]
mycounter = Counter(s)
mycounter = list(mycounter.values())

mycounter = [mycounter[i] for i in range(len(mycounter)) if mycounter[i] > 1]
mycounter = [combinations_count(mycounter[i], 2) for i in range(len(mycounter))]


print(sum(mycounter))

### FIXED CODE ###

from collections import Counter
import math

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

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

[s[i].sort() for i in range(len(s))]

s = [' '.join(s[i]) for i in range(len(s))]
mycounter = Counter(s)
mycounter = list(mycounter.values())

mycounter = [mycounter[i] for i in range(len(mycounter)) if mycounter[i] > 1]
mycounter = [combinations_count(mycounter[i], 2) for i in range(len(mycounter))]

print(sum(mycounter))
### BUGGY CODE ###


def main():
    n = int(input())
    s = input()

    if n <= 3:
        print(0)
        exit()
    r = 0
    for ia in range(0,n-3):
        for ib in range(ia+1, n-1):
            for ic in range(ib+1,n):
                if (ib - ia) != (ic - ib) and s[ia] != s[ib] and s[ia] != s[ic] and s[ib] != s[ic]:
                    r += 1

    print(r)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    s = list(input())
    sr = [0] * n
    sg = [0] * n
    sb = [0] * n
    for i1 in range(n):
        ts = s[i1]
        if ts == 'R':
            sr[i1] = 1
        elif ts == 'G':
            sg[i1] = 1
        else:
            sb[i1] = 1
    if n <= 3:
        print(0)
        exit()
    r = 0
    for ia in range(0,n-3):
        ta = s[ia]
        if ta == 'R':
            r += sum(sg[ia+1:]) * sum(sb[ia+1:])
        elif ta == 'G':
            r += sum(sr[ia+1:]) * sum(sb[ia+1:])
        else:
            r += sum(sg[ia + 1:]) * sum(sr[ia + 1:])
        for ib in range((n - ia)//2+1):
            if ia + ib * 2 < n:
                if ta != s[ia + ib] and ta != s[ia + ib + ib] and s[ia+ib]!= s[ia + ib + ib]:
                    r -= 1
    print(r)

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

n = int(input())
nums = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i == 0:
        ans = nums[i]
    else:
        ans *= nums[i]
if ans <= 10**18:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
nums = list(map(int,input().split()))
ans = 1
if 0 in nums:
  print(0)
else:
  for i in range(n):
    ans *= nums[i]
    if ans > 10**18:
      ans = -1
      break
  print(ans)
### BUGGY CODE ###

import numpy as np

N = int(input())
D = list(map(int, input().split()))
if N > 23:
    print(0)
    exit()
for i in range(13):
    if D.count(i) >= 3:
        print(0)
        exit()

# 深さ優先探索で全通りを探索できるのでは curは０からスタート
def dfs(cur, times):
    global answer
    if cur == N:
        times.sort()
        arr = np.array(times)
        result = (arr[1:] - arr[:-1]).min()
        if result > answer:
            answer = result
    else:
        x = D[cur]
        dfs(cur+1, times + [x])
        dfs(cur+1, times + [24-x])

answer = 0
dfs(0, [0, 24])
print(answer)


### FIXED CODE ###

import numpy as np

N = int(input())
D = list(map(int, input().split()))
if N > 23:
    print(0)
    exit()
for i in range(13):
    if D.count(i) >= 3:
        print(0)
        exit()
    elif D.count(i) == 2 and D.count(i+1) == 2:
        print(1)
        exit()

# 深さ優先探索で全通りを探索できるのでは curは０からスタート
def dfs(cur, times):
    global answer
    if cur == N:
        times.sort()
        arr = np.array(times)
        result = (arr[1:] - arr[:-1]).min()
        if result > answer:
            answer = result
    else:
        x = D[cur]
        dfs(cur+1, times + [x])
        dfs(cur+1, times + [24-x])

answer = 0
dfs(0, [0, 24])
print(answer)
### BUGGY CODE ###

def f():
    h, w, n = map(int, input().split())
    md = 10 ** 9 + 7
    k = [list(map(int, input().split())) for _ in range(n)] + [[h, w]]

    # 壁をマンハッタン距離順に
    k.sort(key=lambda x: x[0] + x[1])

    # 階乗と逆元とコンビネーションを事前準備
    fct = [1]
    re_fct = []
    fct_i = 1
    for i in range(1, h + w + 1):
        fct_i = fct_i * i % md
        fct += [fct_i]
    # fct_i**(md-2)が逆元re_i
    re_i = 1
    p = md - 2
    while p:
        if p & 1:
            re_i = re_i * fct_i % md
        p >>= 1
        fct_i = fct_i ** 2 % md
    for i in range(h + w, -1, -1):
        re_fct += [re_i]
        re_i = re_i * i % md
    re_fct = re_fct[::-1]
    cmb = lambda a, b: fct[a] * re_fct[b] * re_fct[a - b] % md

    # こっから本体
    dp = [0] * (n + 1)
    for i, [r, c] in enumerate(k):
        dpi = cmb(r + c - 2, r - 1) % md
        for j in range(i):
            dr, dc = r - k[j][0], c - k[j][1]
            if dr >= 0 and dc >= 0:
                dpi = (dpi - dp[j] * cmb(dr + dc, dr)) % md
        dp[i] = dpi
    print(dp[-1])

f()

### FIXED CODE ###

def f():
    h, w, n = map(int, input().split())
    md = 10 ** 9 + 7
    k = [list(map(int, input().split())) for _ in range(n)] + [[h, w]]

    # 壁をマンハッタン距離順に
    k.sort(key=lambda x: x[0] + x[1])

    # 階乗と逆元とコンビネーションを事前準備
    fct = [1]
    re_fct = []
    fct_i = 1
    for i in range(1, h + w + 1):
        fct_i = fct_i * i % md
        fct += [fct_i]
    # fct_i**(md-2)が逆元re_i
    re_i = 1
    p = md - 2
    while p:
        if p & 1:
            re_i = re_i * fct_i % md
        p >>= 1
        fct_i = fct_i ** 2 % md
    for i in range(h + w, -1, -1):
        re_fct += [re_i]
        re_i = re_i * i % md
    re_fct = re_fct[::-1]
    cmb = lambda a, b: fct[a] * re_fct[b] * re_fct[a - b] % md

    # こっから本体
    dp = [0] * (n + 1)
    for i, [r, c] in enumerate(k):
        dpi = cmb(r + c - 2, r - 1) % md
        for j in range(i):
            dr, dc = r - k[j][0], c - k[j][1]
            if dr >= 0 and dc >= 0:
                dpi = (dpi - dp[j] * cmb(dr + dc, dr)) % md
        dp[i] = dpi
    print(dp[-1])


f()
### BUGGY CODE ###

def rren(): return list(map(int, input().split()))


a = []
b = []
N, K = rren()

for i in range(N):
    a_t, b_t = rren()
    a.append(a_t)
    b.append(b_t)

count = K
for i in range(K-1):
    mn = min(a)
    ind = a.index(min(a))
    nu = b[ind]
    del a[ind]
    del b[ind]
    count -= nu
    if(count <= 0):
        print(mn)
        break


### FIXED CODE ###

def rren(): return list(map(int, input().split()))


a = set()
b = dict()
N, K = rren()

for i in range(N):
    a_t, b_t = rren()
    if(a_t not in a):
        a.add(a_t)
        b[a_t] = b_t
    else:
        b[a_t] += b_t

li_a = list(a)
li_a.sort()
count = K
for i in range(K):
    count -= b[li_a[i]]
    if(count <= 0):
        print(li_a[i])
        break