There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.
Find the K-th smallest integer in the array after the N operations.
For example, the 4-th smallest integer in the array \{1,2,2,3,3,3\} is 3.

-----Constraints-----
 - 1≤N≤10^5 
 - 1≤a_i,b_i≤10^5 
 - 1≤K≤b_1…+…b_n
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:  
N K
a_1 b_1
:  
a_N b_N

-----Output-----
Print the K-th smallest integer in the array after the N operations.  

-----Sample Input-----
3 4
1 1
2 2
3 3

-----Sample Output-----
3

The resulting array is the same as the one in the problem statement.

Difficulty: introductory

Starter code:

Solutions:
n, k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort()

num_sum = 0

for a, b in ab:
    num_sum += b
    if num_sum >= k:
        print(a)
        return


N, K = map(int, input().split())
arr = [0]*(10**5+1)

for i in range(N):
    a,b = map(int, input().split())
    arr[a] += b

s = 0
for i in range(10**5+1):
    s += arr[i]
    if s >= K:
        print(i)
        break

N, K = map(int, input().split())
s = 0
ab = [[0, 0] for i in range(N)]
for i in range(N):
    ab[i][0], ab[i][1] = map(int, input().split())
ab = sorted(ab)

#print(ab)
for i in range(N):
    s += ab[i][1]
    if s >= K:
        print(ab[i][0])
        break

from sys import stdin
input = stdin.readline
 
from itertools import accumulate
from bisect import bisect_left
 
N, K = map(int, input().split())
 
memo = [0] * 100010
for _ in range(N):
    a, b = map(int, input().split())
    memo[a] += b
 
print(bisect_left(list(accumulate(memo)), K))

n, k = list(map(int, input().split()))
bucket = [0] * 10 ** 5
for i in range(n):
    a, b = list(map(int, input().split()))
    bucket[a - 1] += b

sum_b = 0
for i in range(len(bucket)):
    sum_b += bucket[i]
    if sum_b >= k:
        print((i + 1))
        break


N,K = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(N)]

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

for i in range(N):
  s += ls[i][1]
  if s >= K: break
    
print(ls[i][0])

N,K,*AB=[int(a)for a in open(0).read().split()]
AB=sorted(zip(AB[::2],AB[1::2]))
cnt=0
for a,b in AB:
    cnt+=b
    if cnt>=K:
        print(a)
        return

f=lambda l:map(int,l.split())
N,K=f((p:=input)());c=[0]*(l:=10**5+1);s=0
for i in (r:=range)(N):a,b=f(p());c[a]+=b
for i in r(l):
    s+=c[i]
    if s>=K: print(i);break

from collections import defaultdict

N, K, *ab = list(map(int, open(0).read().split()))
cnt = defaultdict(int)

for a, b in zip(*[iter(ab)] * 2):
    cnt[a] += b
li = [(k, v) for k, v in list(cnt.items())]
li.sort()

for a, b in li:
    if K - b > 0:
        K -= b
    else:
        print(a)
        break


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

a = sorted(a, key = lambda x:x[0])

x = 0
for i in a:
	x += i[1]
	if x >= k:
		break
print(i[0])

n, k = map(int, input().split())
al = [0]*(10**5+1)

for _ in range(n):
    a, b = map(int, input().split())
    al[a] += b

cnt = 0
i = 0
while cnt < k:
    cnt += al[i]
    i += 1

print(i-1)

N,K,*l=map(int,open(0).read().split())
for a,b in sorted(zip(l[::2],l[1::2])):
	if(K:=K-b)<=0:break
print(a)

n,k=map(int,input().split())
s=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    s[a-1]+=b
i=0
while k>0:
    k-=s[i]
    i+=1
print(i)

n,k,*x=list(map(int, open(0).read().split()))
for a,b in sorted(zip(x[0::2],x[1::2])):
    k-=b
    if k < 1:
        print(a);break


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

for i in range(N):
    K = K - A[i][1]
    if K <= 0:
        print((A[i][0]))
        return


def main():
    N, K = list(map(int, input().split()))
    lis = []
    for i in range(N):
        a, b = list(map(int, input().split()))
        lis.append((a, b))

    lis = sorted(lis)

    for i in range(N):
        K -= lis[i][1]
        if K <= 0:
            print((lis[i][0]))
            break


def __starting_point():
    main()

__starting_point()

from collections import defaultdict
n,k = map(int, input().split())
ans = 0
al = []
d = defaultdict(int)
for i in range(n):
  a,b = map(int, input().split())
  al.append(a)
  d[a] += b
al = list(set(al))  
al.sort()
for i in al:
  if k > d[i]:
    k -= d[i]
  else:
    print(i)
    break

# ABC 061: C – Big Array
N, K = [int(i) for i in input().split()]
a, b = [], []
for _ in range(N):
    tmp = input().split()
    a.append(int(tmp[0]))
    b.append(int(tmp[1]))

cnt = [0] * (100000 + 1)

for i in range(N):
    cnt[a[i]] += b[i]

for j in range(100000 + 1):
    if K <= cnt[j]:
        print(j)
        break
    K -= cnt[j]

n,k=map(int,input().split())
l=sorted([list(map(int,input().split()))for i in range(n)])
for a,b in l:
    k-=b
    if k<1:
        print(a);break



def main():
    N, K = list(map(int, input().split()))
    box = []
    for _ in range(N):
        ab = list(map(int, input().split()))
        box.append(ab)

    box.sort(key= lambda x: x[0])
    ans = 0
    for b in box:
        if ans + b[1] < K:
            ans += b[1]
        else:
            print((b[0]))
            return


def __starting_point():
    main()

__starting_point()

n,k=map(int,input().split())
ans=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    ans[a]+=b
    
for i in range(len(ans)):
    k-=ans[i]
    if k<=0:
        print(i)
        break

N, K = map(int, input().split())
a = []
b = []
Sum = 0
for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
s = [*range(len(a))]
sort_s = sorted(s, key = lambda i: a[i])
sort_a = [a[i] for i in sort_s]
sort_b = [b[i] for i in sort_s]
for i in range(N):
    Sum += sort_b[i]
    if Sum >= K:
        print(sort_a[i])
        break

from xml.dom import minidom


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

AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort()

now = -1
idx = 0
while k > 0:
    if idx >= n:
        break
    a, b = AB[idx]
    k -= b
    now = a
    idx += 1
print(now)


n,k=map(int,input().split())
count=0
ba=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    ba[a]+=b
 
for i in range(len(ba)):
    k-=ba[i]
    if k<=0:
        print(i)
        break

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

class Number:
    def __init__(self,number,times):
        self.number=number
        self.times=times

    def __eq__(self, other):
        if self.number==other.number:
            return True
        return False
    def __le__(self, other):
        if self.number<=other.number:
            return True
        return False
    def __lt__(self, other):
        if self.number<other.number:
            return True
        return False
    def __ge__(self, other):
        if self.number>=other.number:
            return True
        return False
    def __gt__(self, other):
        if self.number>other.number:
            return True
        return False

number_list=[]
for i in range(n):
    number,times=[int(i) for i in input().split()]
    number_list.append(Number(number,times))

number_list.sort()


def get(number_list,k):
    i=0
    while True:
        taishou=number_list[i]
        k=k-taishou.times
        if k<=0:
            return taishou.number
        else:
            i+=1
print(get(number_list,k))

N,K,*l=map(int,open(c:=0).read().split())
d={}
for a,b in zip(l[0::2],l[1::2]):d[a]=d.get(a,0)+b
for k in sorted(d.keys()):
	if (c:=c+d[k])>=K:break
print(k)

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


judge = 0
dic = {}


for i in range(n):
    if a[i] in dic:
        dic[a[i]] += b[i]
    else:
        dic[a[i]] = b[i]
#print(dic)
dic = list(dic.items())
dic.sort()
#print(dic)


for i in range(10**9):
    if judge >= k:
        print((dic[i-1][0]))
        break
    else:
        judge += int(dic[i][1])
    #print(judge)


n, k = list(map(int, input().split()))
sum_b = 0
ab_list = []

for i in range(n):
    ab_list.append(list(map(int, input().split())))

ab_list.sort()
for i in range(n):
    a, b = ab_list[i]
    sum_b += b
    if sum_b >= k:
        print(a)
        break


n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
res=k
ab.sort()
for i in range(n):
  res-=ab[i][1]
  if res<=0:
    print(ab[i][0])
    return

N,K,*l=map(int,open(0).read().split())
for a,b in sorted(zip(*[iter(l)]*2)):
	if(K:=K-b)<1:break
print(a)

N, K = map(int, input().split())
d = {}
key = set([])
for _ in range(N):
  a, b = map(int, input().split())
  if a in key:
    d[str(a)] += b
  else:
    key.add(a)
    d[str(a)] = b
key = sorted(list(key))
for k in key:
  if d[str(k)] < K:
    K -= d[str(k)]
  else:
    print(k)
    break

#!/usr/bin/env python

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

d = {}
for i in range(n):
    if a[i] not in d:
        d[a[i]] = b[i]
    else:
        d[a[i]] += b[i]

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

tmp = 0 
for i in range(len(d)):
    tmp += d[i][1]
    if tmp >= k:
        print((d[i][0]))
        return


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

q = []
for i in range(n):
    q.append(list(map(int, input().split())))

q = sorted(q, key=lambda x:x[0])
cnt = 0
i = 0
while cnt < k:
    a, b = q[i]
    cnt += b
    i += 1
print(a)

n, k = map(int, input().split(" "))
a = sorted([list(map(int, input().split(" "))) for i in range(n)])
count = 0
for x, y in a:
  count += y
  if k <= count:
    print(x)
    break
else:
  print("None")

l=[*map(int,open(c:=0).read().split())]
for a,b in sorted(zip(l[2::2],l[3::2])):
	if(c:=c+b)>=l[1]:break
print(a)

f=lambda:map(int,input().split());N,K=f()
for a,b in sorted([*f()]for _ in[0]*N):
    K-=b
    if K<1:print(a);return

N,K = map(int,input().split())
ans = []
for i in range(N):
    ab = list(map(int,input().split()))
    ans.append(ab)
ans.sort()
l = 0
for i in range(N):
    l += ans[i][1]
    if l >= K:
        s = i
        break
print(ans[s][0])

N, K = list(map(int, input().split()))
memory = {}
S = []

for i in range(N):
    a, b = list(map(int, input().split()))
    try:
        memory[a] += b
    except KeyError:
        memory[a] = b

A = sorted(list(memory.keys()))
for a in A:
    if not S:
        S.append(memory[a])
    else:
        S.append(S[-1] + memory[a])

for i in range(N):
    if S[i] >= K:
        print((A[i]))
        break


N,K=list(map(int,input().split()))
ab=list(list(map(int,input().split())) for _ in range(N))
ab.sort()

i=0
while K>0:
    K-=ab[i][1]
    i+=1
print((ab[i-1][0]))


n,k = map(int,input().split())
lst = [0]*10**5
for i in range(n):
  a,b=map(int,input().split())
  lst[a-1] += b
  ans = 0
for j in range(10**5):
  ans += lst[j]
  if ans >= k:
    print(j+1)
    return

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

cnt = 0

ls = []

for i in range(N):
    ls.append(list(map(int, input().split())))

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

for a, b in ls:
    cnt += b
    if cnt >= K:
        break

print(a)


N,K,*l=map(int,open(c:=0).read().split())
d={}
for a,b in zip(l[::2],l[1::2]):d[a]=d.get(a,0)+b
for k in sorted(d.keys()):
	if (c:=c+d[k])>=K:break
print(k)

n, k = map(int, input().split())
S = set()
D = dict()
for _ in range(n):
    a, b = map(int, input().split())
    if a in S:
        D[a] += b
    else:
        S.add(a)
        D[a] = b
L = sorted(S)
cnt = 0
for l in L:
    cnt += D[l]
    if cnt >= k:
        print(l)
        break

# -*- coding: utf-8 -*-
"""
Created on Mon Sep 28 01:21:16 2020

@author: liang
"""

#バケツソートO(n)
N, K = map(int,input().split())
num = [0]*(10**5+1)
for i in range(N):
    a, b = map(int,input().split())
    num[a] += b

tmp = 0
for i in range(10**5+ 1):
    tmp += num[i]
    if tmp >= K:
        print(i)
        break

def main2():
    N, K = map(int, input().split())
    limit = 10**5

    ins = [0 for _ in range(limit + 1)]

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

    c = 0
    for i in range(1, limit + 1):
        c += ins[i]

        if c >= K:
            print(i)
            return

def __starting_point():
    main2()
__starting_point()

N,K = map(int,input().split())
ans = []

for i in range(N):
    ab = list(map(int,input().split()))
    ans.append(ab)

ans.sort()

l = 0
 
for i in range(N):
    l += ans[i][1]
    if l >= K:
        s = i
        break
print(ans[s][0])

n, k = list(map(int, input().split()))
l = sorted([list(map(int, input().split()))for i in range(n)])
for a, b in l:
    k -= b
    if k <1:
        print(a)
        break


n,k = [int(x) for x in input().split()]
a = []
for i in range(n):
  a.append([int(x) for x in input().split()])
a.sort()

c = 0
while k > 0:
  k -= a[c][1]
  c += 1

print(a[c-1][0])

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

lst = [list(map(int, input().split())) for _ in range(N)]
lst.sort(key=lambda x: x[0])
s = 0
for i in range(N):
	s += lst[i][1]
	if s >= K: break
print(lst[i][0])

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

def slv():
    cnt = 0
    for i in range(n):
        cnt += ab[i][1]
        if cnt >= k:
            return print(ab[i][0])

slv()

N,K,*L=[int(a)for a in open(0).read().split()]
L,c=sorted(zip(L[::2],L[1::2])),1
for a,b in L:
    c+=b
    if c>K:print(a);return

n, k = list(map(int, input().split()))
li = []
for i in range(n):
    temp = list(map(int, input().split()))
    li.append(temp)
#print(li)
li.sort()
#print(li)
total=0
for i in range(n):
    if i==n-1:
        #print("here")
        print((li[i][0]))
        break
    total+=li[i][1]
    if total<k:
        continue
    else:
        print((li[i][0]))
        break
    #print(i, total)


def main():
    N, K = list(map(int, input().split()))
    l = []
    cnt = 0
    for _ in range(N):
        a, b = list(map(int, input().split()))
        l.append((a, b))
    l.sort(key=lambda x: x[0])
    for a, x in l:
        cnt += x
        if cnt >= K:
            print(a)
            return

def __starting_point():
    main()

__starting_point()

from collections import defaultdict as dd
from itertools import count
N, K = map(int, input().split())
Cnt = dd(lambda:0)
for _ in range(N):
    a, b = map(int, input().split())
    Cnt[a] += b

num = 0
for i in count(1,1):
    num += Cnt[i]
    if num >= K:
        print(i)
        break

N, K = map(int,input().split())
ls = [0]+[0]*10**5
for i in range(N):
    a,b = map(int,input().split())
    ls[a] += b
ii = 0
for i in range(1,10**5+1):
    ii += ls[i]
    if ii >= K:
        ans = i
        break
    else:
        continue
print(ans)

n,k=map(int,input().split())
num,count=[0]*((10**5)+1),0
for _ in range(n):
  a,b=map(int,input().split())
  num[a]+=b
for i in range(len(num)):
  count+=num[i]
  if count >= k:
    print(i)
    break

import sys
input = sys.stdin.readline

def main():
    n,k = map( int , input().split() )
    A = [ 0 for i in range( 10 ** 5 + 1 ) ]
    for i in range(n):
        a,b = map( int , input().split() )
        A[ a ] += b
    
    i = 0
    sum = 0
    while( sum < k ):
        i += 1
        sum += A[i]
    print(i)



main()

N,K=list(map(int,input().split()))
count=[0]*(100001)
for i in range(1,N+1) :
  a,b=list(map(int,input().split()))
  count[a]+=b
for i in range(1,100001) :
  if K<=count[i] :
    print(i)
    break
  K-=count[i]


# C - Big Array
def main():
    n, k = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    ab.sort()

    i = 0

    while k > 0:
        k -= ab[i][1]
        i += 1
    else:
        print(ab[i-1][0])

if __name__ ==  "__main__":
    main()

from collections import defaultdict
N,K = list(map(int,input().split()))
N_List = defaultdict(int)
for i in range(N):
    Num,Cnt = list(map(int,input().split()))
    N_List[Num] += Cnt

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

ans = 0
for Key,Value in N_List:
    ans += Value
    if ans >= K:
        print(Key)
        break



n,k=map(int,input().split())
s=[0]*10**5
for i in range(n):
    a,b=map(int,input().split())
    s[a-1]+=b
i=0
while k>0:
    k-=s[i]
    i+=1
print(i)

#95 C - Big Array
N,K = map(int,input().split())
lis = []
for _ in range(N):
    a,b = map(int,input().split())
    lis.append((a,b))

lis = sorted(lis,reverse = False)

cnt = 0
num = 0
for a,b in lis:
    cnt += b
    num = a
    if cnt >= K:
        break
print(num)

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]))


#
# abc061 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 4
1 1
2 2
3 3"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N, K = list(map(int, input().split()))
    D = [list(map(int, input().split())) for _ in range(N)]

    D.sort()
    t = 0
    for d in D:
        t += d[1]
        if t >= K:
            print((d[0]))
            break


def __starting_point():
    # unittest.main()
    resolve()

__starting_point()

N,K,*L=[int(a)for a in open(0).read().split()]
for a,b in sorted(zip(L[::2],L[1::2])):
    K-=b
    if K<1:print(a);return

import heapq

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

q = []
for i in range(n):
    q.append(list(map(int, input().split())))

heapq.heapify(q)

cnt = 0
while cnt < k:
    a, b = heapq.heappop(q)
    cnt += b
    
print(a)

#n = int(input())
n, k = list(map(int, input().split()))
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
dic = {}
for i in range(n):
    a, b = list(map(int, input().split()))
    dic[a] = dic.get(a, 0)+b

l = sorted(dic.items())

for a, b in l:
    if k <= b:
        ans = a
        break
    k -= b
print(ans)


#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
dic = defaultdict(int)
d = set()
for i in range(n):
    a,b = readInts()
    d.add(a)
    dic[a] += b
d = sorted(list(d))
ans = 0
for v in d:
    if ans + dic[v] >= k:
        print(v)
        return
    ans += dic[v]


n, k = map(int, input().split())
d = {}
for _ in range(n):
    a, b = map(int, input().split())
    if a in d.keys():
        d[a] += b
    else:
        d[a] = b
cnt = 0
sorted_d = sorted(d.items(), key=lambda x: x[0])
for key, val in sorted_d:
    cnt += val
    if k <= cnt:
        print(key)
        break

n,k=map(int,input().split())
a=[]
for i in range(n):
    A=list(map(int,input().split()))
    a.append(A)
a = sorted(a, key=lambda x: x[0])
b=0
for i in range(n):
    b+=a[i][1]
    if b>=k:
        print(a[i][0])
        return

N,K = map(int,input().split())
nums = []

for _ in range(N):
  a,b = map(int,input().split())
  nums.append([a,b])

nums.sort()
S = 0

for i in range(N+1):
  if S < K:
    S += nums[i][1]
  else:
    print(nums[i-1][0])
    break

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n,k = i_map()

    cnt = 0
    l = []
    for _ in range(n):
        a,b = i_map()
        l.append([a,b])

    l.sort()
    for i,j in l:
        cnt += j
        if cnt >= k:
            print(i)
            break

def __starting_point():
    main()

__starting_point()

# -*- coding: utf-8 -*-
"""
Created on Mon Sep 28 01:14:47 2020

@author: liang
"""

N, K = list(map(int,input().split()))
A = list()
for i in range(N):
    a, b = list(map(int,input().split()))
    A.append((a,b))
A.sort(key= lambda x:x[0])

tmp = 0
for i in range(N):
    a, b = A[i]
    tmp += b
    if tmp >= K:
        print(a)
        break


li = [0]*(10**5+10)
n,k = map(int, input().split())
for i in range(n):
    a,b = map(int, input().split())
    li[a] += b
cnt = 0
ans = 0
for i in range(10**5+10):
    cnt += li[i]
    ans = i
    if cnt >= k:
        break
print(ans)

n, k = map(int, input().split())
query = sorted([tuple(map(int, input().split())) for _ in range(n)])

cnt = 0
i = 0
while cnt < k:
    a, b = query[i]
    cnt += b
    i += 1
print(a)

# s = input()
# n = len(s) - 1
# ans = 0
# for i in range(1 << n):
#     formula = s[0]
#     for j in range(n):
#         if ((i >> j) & 1):
#             formula += '+' + s[j + 1]
#         else:
#             formula += s[j + 1]
#     ans += eval(formula)
# print(ans)
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return list(map(int, stdin.readline().split()))
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, k = nm()
    A = [0] * (10 ** 5 + 1)
    for i in range(n):
        a, b = nm()
        A[a] += b

    sum_num = 0
    for i, a in enumerate(A):
        sum_num += a
        if sum_num >= k:
            print(i)
            return


def __starting_point():
    main()

__starting_point()

N,K=map(int,input().split());c=[0]*(l:=10**5+1);s=0
for i in range(N):a,b=map(int,input().split());c[a]+=b
for i in range(l):
    s+=c[i]
    if s>=K: print(i);break

#!/usr/bin/env python3

def main():
    n, k = list(map(int, input().split()))
    arr = sorted([list(map(int, input().split())) for i in range(n)])
    for ab in arr:
        k -= ab[1]
        if k <= 0:
            ans = ab[0]
            break

    print(ans)


def __starting_point():
    main()

__starting_point()

N,K,*l=list(map(int,open(0).read().split()))
for a,b in sorted(zip(l[::2],l[1::2])):
	if(K:=K-b)<1:break
print(a)


N,K=map(int,input().split())
l=[list(map(int,input().split()))for i in range(N)]
l.sort(key=lambda x: x[0])
ans=0
for i in l:
    if K==0:
        break
    K-=min(K,i[1])
    ans=i[0]
print(ans)

n,k = list(map(int,input().split()))
A = []
for _ in range(n):
    A.append(list(map(int,input().split())))
A.sort(key=lambda x: x[0])
cnt = 0
while k>0:
    k-=A[cnt][1]
    cnt+=1
print((A[cnt-1][0]))


import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n, k = inl()
    v = []
    for i in range(n):
        a, b = inl()
        v.append((a, b))
    v.sort(reverse=True)
    c = k - 1
    while v:
        a, b = v.pop()
        if b > c:
            return a
        c -= b


print(solve())


N,K=map(int,input().split())
cnt=0
P=[]
for i in range(N):
    a,b=map(int,input().split())
    P.append((a,b))

P=sorted(P)
for i in range(N):
    cnt+=P[i][1]
    if cnt>=K:
        print(P[i][0])
        break

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


N, K = map(int, input().split())
d = {}
for i in range(N):
    a, b = map(int, input().split())
    d[a] = d.get(a, 0) + b

cnt = 0
for k in sorted(d.keys()):
    cnt += d[k]
    if cnt >= K:
        print(k)
        break

n, k = map(int,input().split())
a_b = [ list(map(int, input().split())) for _ in range(n)  ]
a_b = sorted(a_b, key=lambda x: x[0] )

count = 0
for i in range(len(a_b)):
    a, b = a_b[i]
    count += b
    if count >= k:
        print(a)
        break

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

cur = 0
for i in range(100100):
    cur += arr[i]
    if cur >= k:
        print(i)
        break

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

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

cnt = 0
for i, c in enumerate(bucket):
    if c == 0:
        continue
    cnt += c
    if cnt >= K:
        print(i)
        return

N,K=map(int,input().split())
d={}
for i in range(N):
  a,b=map(int,input().split())
  if a not in d:
    d[a]=b
  else:
    d[a]+=b
d=sorted(d.items())
for i in d:
  K-=i[1]
  if K<=0:
    print(i[0])
    break

n,k = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(n)])
cnt = 0
for a,b in ab:
    cnt += b
    if cnt >= k: break
print(a)

n, k = list(map(int, input().split()))
ar = {}
for i in range(n):
    a, b = list(map(int, input().split()))
    if (a in ar) == True:
        ar[a] += b
    else:
        ar[a] = b

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


N,K=map(int,input().split())
A={}
for i in range(N):
  a,b=map(int,input().split())
  A[a]=A.get(a,0)+b
A=sorted(A.items())

cnt=0
for n,k in A:
  cnt+=k
  if cnt>=K:
    print(n)
    return

N,K=list(map(int,input().split()))
A=[list(map(int,input().split())) for _ in range(N)]
A=sorted(A, key=lambda x: x[0])

cnt=0
for i in range(N):
    a,b=A[i]
    A[i][1]+=cnt
    cnt=A[i][1]

for i in range(N):
    a,b=A[i]
    if K<=b:break
print(a)


import bisect

n,k=list(map(int,input().split()))
hairetu=[0]*100001

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

ruiseki=[0]*100001
for i in range(1,100001):
    ruiseki[i]=ruiseki[i-1]+hairetu[i]

print((bisect.bisect_left(ruiseki,k)))


N,K,*l=map(int,open(c:=0).read().split())
for a,b in sorted(zip(l[::2],l[1::2])):
	if(c:=c+b)>=K:break
print(a)

xx = []
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
xx = sorted(ab, key= lambda x:x[0])

ans = 0
for i in range(n):
  ans += xx[i][1]
  if ans >=  k:
    print(xx[i][0])
    break

from collections import Counter

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

d = Counter()
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += b

x = sorted(d.items(), key=lambda x: x[0])
cnt = 0
for a, b in x:
    cnt += b
    if cnt >= k:
        print(a)
        return

AMAX = 10**5
count = [0] * (AMAX + 1)

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

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

for ans in range(AMAX + 1):
    if K <= count[ans]:
        print(ans)
        break
    K -= count[ans]