CodeEff/ECCO huggingface dataset:
# Original solution
def main():
    N, K = list(map(int, input().split()))
    ary = []
    i = 0
    while i < N:
        a, b = list(map(int, input().split()))
        ary += [a] * b
        i += 1

    ans = sorted(ary)[K-1]
    print(ans)

main()


# Optimized solution
def main():
    N, K = list(map(int, input().split()))
    ab = []
    i = 0
    while i < N:
        a, b = list(map(int, input().split()))
        ab.append([a, b])
        i += 1

    ary = sorted(ab)
    j = 0
    for i in ary:
        j += i[1]
        if j >= K:
            print((i[0]))
            break

main()
# Original solution
int_n, int_k = list(map(int, input().split()))

ar_int = list()

for i in range(int_n):
    int_a, int_b = list(map(int, input().split()))
    for x in range(int_b):
        ar_int.append(int_a)

print((sorted(ar_int)[int_k - 1]))


# Optimized solution
int_n, int_k = list(map(int, input().split()))

li_wk = list()

for i in range(int_n):
    li_wk.append(list(map(int, input().split())))

li_wk.sort(key=lambda x: x[0])

counter = 1
for l in li_wk:
    if counter <= int_k <= (counter + l[1] - 1):
        print((l[0]))
    counter += l[1]
# Original solution
L=lambda:list(map(int,input().split()))
n,k=L()
ab=sorted([L()for _ in range(n)])
for a,b in ab:
  k-=b
  if k<=0:
    print(a)
    exit()

# Optimized solution
n,k=list(map(int,input().split()))
ab=[]
for _ in range(n):
  a,b=list(map(int,input().split()))
  ab.append((a,b))
ab.sort()
for i,j in ab:
  k-=j
  if k<=0:
    print(i)
    exit()
# Original solution
N, M = list(map(int, input().split(' ')))
A = []
for i in range(N):
    a, b = list(map(int, input().split(' ')))
    A.append([a]*b)
A.sort()
A = [i for v in A for i in v]
print((A[M-1]))


# Optimized solution
N, M = list(map(int, input().split(' ')))
A = []
for i in range(N):
    a, b = list(map(int, input().split(' ')))
    A.append([a, b])
A.sort()
i = -1
count=0
while(True):
    i += 1
    count += A[i][1]
    if count >= M:
        print((A[i][0]))
        break
# Original solution
f=lambda:list(map(int,input().split()));n,k=f();c=0
for a,b in sorted(list(f())for _ in range(n)):
  c+=b
  if c>=k:print(a);break

# Optimized solution
f=lambda:list(map(int,input().split()));n,k=f();c=0
for a,b in sorted(list(f())for _ in[0]*n):
  c+=b
  if c>=k:print(a);break
# Original solution
N,K=list(map(int,input().split()))
S=[]
for i in range(N):
  a,b=list(map(int,input().split()))
  for i in range(b):
    S.append(a)
S=sorted(S)
print((S[K-1]))

# Optimized solution
N,K=list(map(int,input().split()))
S={}
for i in range(N):
  a,b=list(map(int,input().split()))
  if a in S:
    S[a]+=b
  else:
    S[a]=b
T=sorted(S.items())
count=0
for i in range(len(T)):
  count+=T[i][1]
  if count>=K:
    print((T[i][0]))
    break
# Original solution
n, k = list(map(int,input().split()))
ans = []
for i in range(n):
    a, b = list(map(int,input().split()))
    for j in range(b):
        ans.append(a)
#print(ans)

ans.sort()

print((ans[k - 1]))

# Optimized solution
n, k = list(map(int,input().split()))
ans = [0]*100000
for i in range(n):
    a, b = list(map(int,input().split()))
    ans[a-1] += b
#print(ans)

counter = 0

while(k > 0):
    k -= ans[counter]
    counter += 1

print(counter)
    
#1
# Original solution
n,k=list(map(int,input().split()))
num=[list(map(int,input().split()))for _ in range(n)]
p=0
num.sort()
for i in range(n):
    p+=num[i][1]
    if k<=p:
        ans=num[i][0]
        print(ans)
        exit()


# Optimized solution
n,k=list(map(int,input().split()))
a=[list(map(int,input().split()))for i in range(n)]
a.sort(key=lambda x:x[0])
count=0
for i,j in a:
    count+=j
    if k<=count:
        print(i)
        exit()
# Original solution
n,k=list(map(int,input().split()))
a=[list(map(int,input().split()))for i in range(n)]
a.sort(key=lambda x:x[0])
count=0
for i,j in a:
    count+=j
    if k<=count:
        print(i)
        exit()

# Optimized solution
n,k=list(map(int,input().split()))
t=[tuple(map(int,input().split()))for i in range(n)]
t=sorted(t,key=lambda t:t[0])
total=0
for i in range(n):
    total+=t[i][1]
    if k<=total:
        print((t[i][0]))
        exit()
# Original solution
N, K = list(map(int, input().split()))

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = list(map(int, input().split()))
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])

j = 0
index = 0
while j < K:
    j += ab[index][1]
    if j < K:
        index += 1

print((ab[index][0]))


# Optimized solution
N, K = list(map(int, input().split()))

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = list(map(int, input().split()))
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])


total = 0
for pair in ab:
    total += pair[1]
    if total >= K:
        print((pair[0]))
        break
# Original solution
n, k = list(map(int, input().split()))

s = []

for i in range(n):
    a, b = list(map(int, input().split()))
    for j in range(b):
        s.append(a)

s = sorted(s)

print((s[k-1]))

# Optimized solution
n, k = list(map(int, input().split()))

A = []

for i in range(n):
    c = []
    a, b = list(map(int, input().split()))
    c.append(a)
    c.append(b)
    A.append(c)

A.sort(key=lambda x:x[0])


f = k
i = 0
while f > 0:
    f -= A[i][1]
    i += 1

print((A[i-1][0]))
# Original solution
from collections import Counter
N,K = list(map(int,input().split()))
tmp = Counter()
for i in range(N):
    a,b = list(map(int,input().split()))
    tmp.update([a]*b)

print((sorted(tmp.elements())[K-1]))

# Optimized solution
n,k=[int(x) for x in input().split()]
s=[]
for i in [None]*n:
    a,b=[int(x) for x in input().split()]
    s.append((a,b))
s=sorted(s,key=lambda x : x[0])
for i in s:
    if i[1]>=k:
        print((i[0]))
        break
    else:
        k-=i[1]
# Original solution
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    L=[]
    for i in range(N):
        a,b=list(map(int,input().split()))
        for j in range(b):
            L.append(a)
    L.sort()
    print((L[K-1]))

# Optimized solution
if __name__ == '__main__':
    N,K=list(map(int,input().split()))
    AB=[tuple(map(int,input().split())) for i in range(N)]
    AB.sort(key=lambda x:x[0])
    for a,b in AB:
        K-=b
        if K<=0:
            print(a)
            break
# Original solution
n , k = list(map(int, input().split()))
x=[]
for i in range(n):
    a , b = list(map(int, input().split()))
    x+=[a]*b
x.sort()
print((x[k-1]))


# Optimized solution
n , k = list(map(int, input().split()))
x=[]
j=0
c=0
for i in range(n):
    a , b = list(map(int, input().split()))
    x.append([a,b])
x.sort(key = lambda x :x[0])
while True:
    c+=x[j][1]
    if c>=k:
        print((x[j][0]))
        break
    j+=1
# Original solution
N,K=list(map(int,input().split()))
ans=[]
for i in range(N):
    a,b=list(map(int,input().split()))
    tmp_ = [a]*b
    ans.extend(tmp_)
ans = sorted(ans)
print((ans[K-1]))

# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################
 
N, K = list(map(int, input().split()))
 
ans = [0] * (10**5+1)
for i in range(N):
    a, b = list(map(int, input().split()))
    ans[a] += b
 
remain = K
for i in range(10**5+1):
    if ans[i] == 0:
        continue
 
    remain -= ans[i]
    if remain <= 0:
        print(i)
        exit()
# Original solution
def main():
    n,k=list(map(int,input().split()))
    arr = []
    for _ in range(n):
        a,b=list(map(int,input().split()))
        arr.extend([a]*b)
    arr.sort()
    print((arr[k-1]))
    
if __name__ == "__main__":
    main()

# Optimized solution
def main():
    n,k=list(map(int,input().split()))
    arr = []
    for _ in range(n):
        a,b=list(map(int,input().split()))
        arr.append((a, b))
    arr.sort()
    for x, c in arr:
        if k <= c:
            print(x)
            break
        else:
            k -= c
    
if __name__ == "__main__":
    main()
# Original solution
import heapq
n,k = list(map(int,input().split()))
c = []
heapq.heapify(c)
for i in range(n):
    a,b = list(map(int,input().split()))
    c+=([a]*b)
    heapq.heapify(c)
l = heapq.nsmallest(k,c)
print((l[-1]))


# Optimized solution
import heapq
n,k = list(map(int,input().split()))
d = {}
z = []
for i in range(n):
    a,b = list(map(int,input().split()))
    z.append([a,b])
    d[a] = 0
for i in range(len(z)):
    d[z[i][0]]+=z[i][1]
c = sorted(d.keys())
l=0
for i in range(len(c)):
    if(k<=0):
        print((c[i-1]))
        l+=1
        break
    k-=d[c[i]]
if(l!=1):
    print((c[-1]))
# Original solution
N,K=list(map(int,input().split()))
from collections import defaultdict
data=defaultdict(int)
for n in range(N):
    a,b=list(map(int,input().split()))
    data[a]+=b
now=0
for i in range(len(data)):
    idx=min(data.keys())
    now+=data[idx]
    if now>=K:
        print(idx)
        break
    data.pop(idx)

# Optimized solution
N,K=list(map(int,input().split()))
from collections import defaultdict
data=[]
for n in range(N):
    data.append(tuple(map(int,input().split())))
data.sort(key=lambda x:x[0])
now=0
for i in range(len(data)):
    now+=data[i][1]
    if now>=K:
        print((data[i][0]))
        break
# Original solution
# 操作回数（N）および数を求めたい順位（K）を入力する
N, K = list(map(int, input().split()))
# 整数を格納するリスト（list_num）を定義する
list_num = []
# 各操作において、、
for _ in range(N):
    # 挿入する整数（a）とその個数（b）を入力する
    a, b = list(map(int, input().split()))
    # list_numにaをb個だけ挿入する
    list_num.extend([a] * b)
# list_numを昇順にソートする
list_num.sort()
# K番目に小さい数を返す
print((list_num[K - 1]))

# Optimized solution
# 操作回数（N）および数を求めたい順位（K）を入力する
N, K = list(map(int, input().split()))
# 挿入する整数（a）とその個数（b）の組を格納するリスト（list_ab）を定義する
list_ab = []
# 各操作において、、
for _ in range(N):
    # aおよびbを入力する
    a, b = list(map(int, input().split()))
    # list_abにaとb個の組を追加する
    list_ab.append((a, b))
# list_abをaが昇順に並ぶようにソートする
list_ab.sort()
# bの合計を計算する変数（sum_b）を定義する
sum_b = 0
# 各a、bの組について、、
for a, b in list_ab:
    # sum_bにbを足す
    sum_b += b
    # sum_bがK以上になった場合、、
    if sum_b >= K:
        # aを出力する
        print(a)
        break
# Original solution
n, k = list(map(int, input().split()))
c = []
for i in range(n):
    a, b = list(map(int, input().split()))
    c.extend([a]*b)
print((sorted(c)[k-1]))


# Optimized solution
n, k = list(map(int, input().split()))
ab = []
count = 0
for i in range(n):
    ab.append(list(map(int, input().split())))
ab.sort()
for i in range(k):
    count += ab[i][1]
    if(count >= k):
        print((ab[i][0]))
        break
# Original solution
n, k = list(map(int, input().split()))
AB = []
for i in range(n):
    a, b = list(map(int, input().split()))
    AB.append((a, b))
AB.sort()
cnt = 0
X = []
for i in range(n):
    a, b = AB[i]
    X += [a]*b
    cnt += b
    if cnt > k:
        break
X.sort()
print((X[k-1]))


# Optimized solution
n, k = list(map(int, input().split()))
AB = []
for i in range(n):
    a, b = list(map(int, input().split()))
    AB.append((a, b))
AB.sort()
cnt = 0
for a, b in AB:
    cnt += b
    if cnt >= k:
        print(a)
        break
# Original solution
n,k = list(map(int, input().split()))
lst = []

for i in range(n):
    a,b = list(map(int, input().split()))
    lst += [a for i in range(b)]
# print(lst)
lst.sort()
print((lst[k-1]))

# Optimized solution
n,k = list(map(int, input().split()))
lst = [None for i in range(n)]

for i in range(n):
    a,b = list(map(int, input().split()))
    lst[i] = (a,b)

# print(lst)
lst.sort(key=lambda x:x[0])
# print(lst)

count = 0
for i in range(n):
    count += lst[i][1]
    if count>=k:
        print((lst[i][0]))
        exit()
# Original solution
N,K=[int(i) for i in input().split(" " )]
s = []
for i  in  range(N):
  s.append([int(ii) for ii in input().split(" ")])

p = []
for i in s:
  _  = [p.append(i[0]) for ii in range(i[1])]

p.sort()

print((p[K-1]))


# Optimized solution
N,K=[int(i) for i in input().split(" " )]
s = []
for i  in  range(N):
  s.append([int(ii) for ii in input().split(" ")])

s.sort( key=lambda x: x[0])  
countPush = 0
for i in s:
   countPush += i[1]
   if(countPush >= K ):
     print((i[0]))
     break
# Original solution
N, K = list(map( int, input().split()))
A = []
for i in range(N):
    a, b = list(map( int, input().split()))
    A += [a]*b
    A.sort()
    A = A[:K]
print((A[K-1]))

# Optimized solution
N, K = list(map( int, input().split()))
A = [ [0]*2 for _ in range(N)]
for i in range(N):
    A[i] = list(map( int, input().split()))
A.sort()
L = 0
for i in range(N):
    L += A[i][1]
    if L >= K:
        print((A[i][0]))
        break
# Original solution
N,K=list(map(int,input().split()))

ablist=[]
for _ in range(N):
  a,b=list(map(int,input().split()))
  ablist.append((a,b))
ablist.sort()
  
aslist=[]
s=0
for a,b in ablist:
  s+=b
  aslist.append((a,s))
#print(aslist)

for a,s in aslist:
  if s>=K:
    print(a)
    break

# Optimized solution
N,K=list(map(int,input().split()))

ablist=[]
for _ in range(N):
  a,b=list(map(int,input().split()))
  ablist.append((a,b))
ablist.sort()
  
s=0
for a,b in ablist:
  s+=b
  if s>=K:
    print(a)
    break
# Original solution
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = list(map(int, input().split()))
ans = []
for i in range(n):
    a, b = readints()
    for j in range(b):
        ans.append(a)
aannss = sorted(ans)
print((aannss[k-1]))


# Optimized solution
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = list(map(int, input().split()))
ab = [readints() for _ in range(n)]
# print(ab)
abab = sorted(ab)
# print(abab)
tmp = 0
for i in range(n):
    tmp += abab[i][1]
    if tmp >= k:
        print((abab[i][0]))
        break
# Original solution
n, k = list(map(int, input().split()))
num = []
cnt = [0] * (10**5 + 1)
for _ in range(n):
    a, b = list(map(int, input().split()))
    if a not in num:
        num.append(a)
    cnt[a] += b
num.sort()
ans = 0
for i in num:
    if cnt[i] >= k:
        ans = i
        break
    else:
        k -= cnt[i]
print(ans)

# Optimized solution
n, k = list(map(int, input().split()))
cnt = [0] * (10**5 + 1)
for _ in range(n):
    a, b = list(map(int, input().split()))
    cnt[a] += b
for i in range(10**5 + 1):
    if k <= cnt[i]:
        ans = i
        break
    else:
        k -= cnt[i]
print(ans)
# Original solution
from collections import defaultdict
n, k = list(map(int, input().split()))
dic = defaultdict(int)
for i in range(n):
    a, b = list(map(int, input().split()))
    dic[a] += b

t = sorted(dic.keys())
for i in t:
    k -= dic[i]
    if k <= 0:
        print(i)
        break

# Optimized solution
n, K = list(map(int, input().split()))
rec = [0] * (10 ** 5 + 5)
for i in range(n):
    a, b = list(map(int, input().split()))
    rec[a] += b

for i in range(10 ** 5 + 1):
    if rec[i] > 0:
        K -= rec[i]
        if K <= 0:
            print(i)
            exit()
# Original solution
import heapq
N, K = list(map(int,input().split()))
Q = []
for i in range(N):
    a, b = list(map(int,input().split()))
    for j in range(b):
        heapq.heappush(Q,a)
for i in range(K-1):
    heapq.heappop(Q)
print((heapq.heappop(Q)))

# Optimized solution
N, K = list(map(int,input().split()))
Q = [0 for i in range(N)]
for i in range(N):
    Q[i] = list(map(int,input().split()))
Q.sort()
cnt = 0
j = 0
while cnt < K:
    cnt += Q[j][1]
    j += 1
print((Q[j-1][0]))
# Original solution
import heapq as q

n, k = list(map(int, input().split()))
l = []
q.heapify(l)

for i in range(n):
    a, b = list(map(int, input().split()))
    for j in range(b):
        q.heappush(l, a)

for i in range(k):
    ans = q.heappop(l)
print(ans)

# Optimized solution
n, k = list(map(int, input().split()))
l = [0]*(10**5+10)

for i in range(n):
    a, b = list(map(int, input().split()))
    l[a] += b

sum = 0
for i in range(len(l)):
    sum += l[i]
    if sum >= k:
        print(i)
        break
# Original solution
N, K = list(map(int,input().split()))
t = []

for _ in range(N):
    a,b = list(map(int,input().split()))
    for j in range(b):
        t.append(a)
t.sort()

print((t[K-1]))

# Optimized solution
N, K = list(map(int,input().split()))
a_max = 100000
t = [0 for _ in range(a_max)]

for _ in range(N):
    a, b = list(map(int,input().split()))
    t[a-1] += b

cnt = 0
for i in range(a_max):
    cnt += t[i]
    if cnt >= K:
        ans = i+1
        break

print(ans)
# Original solution
N, K = list(map(int, input().split()))
arr = []
for i in range(N):
  a, b = list(map(int, input().split()))
  arr += [a]*b

arr.sort()
print((arr[K-1]))

# Optimized solution
N, K = list(map(int, input().split()))
cnt = [0]*100001
S = set()
for i in range(N):
  a, b = list(map(int, input().split()))
  cnt[a-1] += b
  S.add(a)

acc = 0
for s in sorted(S):
  acc += cnt[s-1]
  if acc >= K:
    print(s)
    break
# Original solution
n,k=list(map(int,input().split()))
c=[]
for i in range(n):
  a,b=list(map(int,input().split()))
  c+=[a]*b
c.sort()
print((c[k-1]))

# Optimized solution
n,K=list(map(int,input().split()));c={}
for i in range(n):
  a,b=list(map(int,input().split()))
  if a in c:c[a]+=b
  else:c[a]=b
for k,v in sorted(c.items()):
  K-=v
  if K<=0:print(k);exit()
# Original solution
n,k=[int(x) for x in input().rstrip().split()]
dic={}
for i in range(n):
  a,b=[int(x) for x in input().rstrip().split()]
  if a not in dic:
    dic[a]=b
  else:
    dic[a]+=b

dic=sorted(dic.items())

now=0
for i,v in dic:
  now+=v
  if k<=now:
    print(i)
    break


# Optimized solution
n,k=[int(x) for x in input().rstrip().split()]
dic={}
for i in range(n):
  a,b=[int(x) for x in input().rstrip().split()]
  if a not in dic:
    dic[a]=b
  else:
    dic[a]+=b

dic=sorted(list(dic.items()),key=lambda x:x[0])

now=0
for i,v in dic:
  now+=v
  if k<=now:
    print(i)
    break
# Original solution
n, k = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
Table = []

for i in range(n):
    Table.extend([a[i][0]]*a[i][1])

print((sorted(Table)[k-1]))


# Optimized solution
from operator import itemgetter

n, k = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=itemgetter(0))
m = 0

for i in range(n):
    m += a[i][1]
    if k <= m:
        print((a[i][0]))
        break
# Original solution
N, K = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N)]
ans = []

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

ans.sort()
print((ans[K-1]))

# Optimized solution
N, K = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N)]
ab.sort()

n = 0
for i in range(N):
  if n + ab[i][1] < K:
    n += ab[i][1]
  else:
    print((ab[i][0]))
    break
# Original solution
from collections import deque
n,k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
cnt = 0
ans = 0
for a,b in ab:
  ans = a
  cnt += b
  if cnt >= k:break
print(ans)

# Optimized solution
n,k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
cnt = 0
for a,b in ab:
  cnt += b
  if cnt >= k: break
print(a)
# Original solution
n,k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
ans = []
for a,b in ab:
    ans += [a] * b
ans.sort()
print((ans[k-1]))

# Optimized solution
n,k = list(map(int, input().split()))
ab = sorted([list(map(int, input().split())) for _ in range(n)])
for a,b in ab:
    if b <= k:
        k -= b
    else:
        k = 0
    if k == 0:
        print(a)
        exit()
# Original solution
n,k = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(n)]
l = []
for i in range(n):
  l+=[ab[i][0]]*(ab[i][1])
l.sort()
print((l[k-1]))

# Optimized solution
n,k = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort()
tmp=0
i=0

while tmp<k:
  tmp+=ab[i][1]
  hoge=ab[i][0]
  i+=1

print(hoge)
# Original solution
n, k = [int(x) for x in input().split()]

arr = []
for i in range(n):
    a, b = [int(x) for x in input().split()]
    arr += [a] * b

arr.sort()

print((arr[k-1]))

# Optimized solution
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

th = 0
for i in range(1, 10**5+1):
    if arr[i] != 0:
        th += arr[i]
    if th >= K:
        print(i)
        exit()
# Original solution
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

th = 0
for i in range(1, 10**5+1):
    if arr[i] != 0:
        th += arr[i]
    if th >= K:
        print(i)
        exit()

# Optimized solution
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()
# Original solution
import sys
sys.stdin

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

# Optimized solution
import sys
sys.stdin.readline

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()
# Original solution
import sys
sys.stdin.readline

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

# Optimized solution
from sys import stdin
input = stdin.readline

N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()
# Original solution
N, K = list(map(int, input().split()))
c = []
for _ in range(N):
    a, b= list(map(int, input().split()))
    for i in range(b):
        c.append(a)
print((sorted(c)[K-1]))

# Optimized solution
N, K = list(map(int, input().split()))
num = [0]*(10**5+1)
for i in range(N):
    a, b= list(map(int, input().split()))
    num[a] += b
for i in range(1, 10**5+1):
    if K <= num[i]:
        print(i)
        exit()
    K -= num[i]