CodeEff/ECCO huggingface dataset:
# Original solution
import heapq
N,K=list(map(int,input().split()))
c=[]
for i in range(N):
	a,b=list(map(int,input().split()))
	for j in range(b):
		heapq.heappush(c,a)

for i in range(len(c)):
	val=heapq.heappop(c)
	if i==K-1:
		print(val)
		break


# Optimized solution
import heapq
N,K=list(map(int,input().split()))
c=[]
for i in range(N):
	heapq.heappush(c, tuple( map(int,input().split()) ) )

cnt=0
for i in range(len(c)):
	val=heapq.heappop(c)
	cnt+=val[1]
	if K<=cnt:
		print(val[0])
		break
# Original solution
a=[];n,k=list(map(int,input().split()))
for _ in[0]*n:
    b,c=list(map(int,input().split()))
    a+=[b]*c
print((sorted(a)[~-k]))

# Optimized solution
a=[];n,k=list(map(int,input().split()))
for _ in[0]*n:a+=[list(map(int,input().split()))]
a.sort();i=0
while k>0:k-=a[i][1];i+=1
print((a[~-i][0]))
# Original solution
a=[];n,k=list(map(int,input().split()))
for _ in[0]*n:a+=[list(map(int,input().split()))]
a.sort();i=0
while k>0:k-=a[i][1];i+=1
print((a[~-i][0]))

# Optimized solution
n,k=list(map(int,input().split()));i=0
a=sorted(list(map(int,input().split()))for _ in[0]*n)
while k>0:k-=a[i][1];i+=1
print((a[~-i][0]))
# Original solution
n,k=list(map(int,input().split()))
arr=[]
for i in range(n):
  a,b=list(map(int,input().split()))
  for j in range(b):
    arr.append(a)
arr.sort()
print((arr[k-1]))

# Optimized solution
n,k=list(map(int,input().split()))
nums=[]
for i in range(n):
  nums.append(list(map(int,input().split())))
nums.sort(key=lambda x:x[0])
cnt=0
i=0
while cnt<k:
  cnt+=nums[i][1]
  if cnt>=k:
    print((nums[i][0]))
    break
  i+=1
# Original solution
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 = sorted(L)
print((L[K - 1]))

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

L = []
for i in range(100000):
	L.append(0)

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

sm = 0
for i in range(100000):
	sm += L[i]
	if sm >= K:
		print((i + 1))
		break
# Original solution
N, K = list(map(int, input().split()))
an = []
for i in range(N):
  a, b = list(map(int, input().split()))
  for j in range(b):
    an.append(a)
an.sort()
ans = an[K-1]
print(ans)

# Optimized solution
N, K = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(N)]
a.sort()
ans = a[0][0]
b = a[0][1]
i = 1
while b < K:
  ans = a[i][0]
  b += a[i][1]
  i += 1
print(ans)
# Original solution
N,K = [int(i) for i in input().split()]
list = []

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

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


# Optimized solution
N,K = [int(i) for i in input().split()]
dic = {}
sum = 0

for i in range(N):
    a,b = [int(i) for i in input().split()]
    if a in dic:
        dic[a] += b
    else:
        dic[a] = b

dic = sorted(dic.items())

for i in range(len(dic)):
    sum += dic[i][1]
    if K <= sum:
        print((dic[i][0]))
        break
# Original solution
N, K = list(map(int, input().split()))
A = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    A += [a] * b

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


# Optimized solution
N, K = list(map(int, input().split()))
AB = list(list(map(int, input().split())) for _ in range(N))

AB.sort()
if AB[0][1] >= K:
    ans = AB[0][0]
else:
    for i in range(1,N):
        AB[i][1] += AB[i-1][1]
        if AB[i][1] >= K:
            ans = AB[i][0]
            break
print(ans)
# Original solution
n,k=list(map(int,input().split()))

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


# Optimized solution
n,k=list(map(int,input().split()))
li = [list(map(int, input().split())) for i in range(n)]
li.sort()
c=0
for i in range(n):
  c+=li[i][1]
  if c>=k:
    print((li[i][0]))
    
    break
# 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 = arr + [a]*b
arr.sort()
print((arr[K-1]))


# Optimized solution
N,K = [int(x) for x in input().split()]
arr=[]
for i in range(N):
    arr.append([int(x) for x in input().split()])
    
arr.sort(key=lambda tup: tup[0])

for i in range(N):
    K=K-arr[i][1]
    if K<=0:
        print((arr[i][0]))
        break
# Original solution
def main():
    l = []
    N, K = list(map(int, input().split()))
    for i in range(N):
        a, b = list(map(int, input().split()))
        l.extend([a for j in range(b)])

    l = sorted(l)
    print((l[K-1]))

main()

# Optimized solution
def main():
    l = []
    N, K = list(map(int, input().split()))
    d_num = {i: 0 for i in range(100002)}
    for i in range(N):
        a, b = list(map(int, input().split()))
        d_num[a] = d_num[a] + b

    for i in range(100002):
        K = K - d_num[i+1]

        if K <= 0:
            break

    print((i+1))

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

numList = []

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

    for _ in range(b):
        numList.append(a)

numList.sort()

print((numList[K-1]))

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

numList = []
for _ in range(N):
    numList.append(list(map(int, input().split())))

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

idx = 0
while True:
    K = K - numList[idx][1]
    if K <= 0:
        print((numList[idx][0]))
        exit()
    idx = idx + 1
# Original solution
N, K = [int(i) for i in input().split()]
ans = []
for i in range(N):
    A,B = [int(i) for i in input().split()]
    for b in range(B):
        ans.append(A)
ans.sort()
print((ans[K-1]))




# Optimized solution
N, K = [int(i) for i in input().split()]
ans = []
A = [[]*2]*N
num = 0
for i in range(N):
    A[i] = [int(i) for i in input().split()]
A.sort()
i = 0
while num < K:
    num += A[i][1]
    i += 1

print((A[i-1][0]))
# Original solution
import sys
N,K=list(map(int, input().split()))
p=[]
for i in range (0,N):
  r=list(map(int, input().split() )) 
  p.append(r)
p.sort()
q=[]
for i in range(0,N):
  q+=[p[i][0]]*p[i][1]
  if len(q)>K:
    print((q[K-1]))
    sys.exit()

# Optimized solution
import sys
N,K=list(map(int, input().split()))
p=[]
for i in range (0,N):
  r=list(map(int, input().split() )) 
  p.append(r)
p.sort()
k=0
for i in range(0,N):
  k+=p[i][1]
  if k>=K:
    print((p[i][0]))
    sys.exit()
# Original solution
import sys
N,K=list(map(int,input().split()))
nums = []
for _ in range(N):
  a,b = list(map(int,sys.stdin.readline().split()))
  nums += [a for _ in range(b)]
nums.sort()
print((nums[K-1]))

# Optimized solution
import sys
N,K=list(map(int,input().split()))
nums = {}
for _ in range(N):
  a,b = list(map(int,sys.stdin.readline().split()))
  if a in nums:
    nums[a] += b
  else:
    nums[a] = b

cnt = 0
for key in sorted(nums.keys()):
  cnt += nums[key]
  if cnt >= K:
    print(key)
    exit()
# Original solution
N, K = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
A.sort()
for i in range(N):
    if K>A[i][1]:
      K -= A[i][1]
    else:
      ans = A[i][0]
      break
print(ans)

# Optimized solution
def solve():
  ans = 0
  cnt = 0
  N, K = list(map(int, input().split()))
  A = [list(map(int, input().split())) for _ in range(N)]
  A.sort()
  for a,b in A:
    cnt += b
    if cnt>=K:
      ans = a
      break
  return ans
print((solve()))
# Original solution
import sys
input = sys.stdin.readline

def two_int():
    N, K = list(map(int, input().split()))
    return N,K

def one_int():
    return int(eval(input()))

def one_str():
    return eval(input())

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

from collections import defaultdict


N,K = two_int()

query = []
for i in range(N):
    query.append(two_int() )

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

dicts = defaultdict(int)
count = 0
sums = 0

for [a,b] in query:
    temp = 0
    
    for k,v in list(dicts.items()):
        if k>a:
            dicts[k] += b
        if temp <= k <= a:
            temp = k
            
    dicts[a] = b+dicts[temp]
    sums += b
    if sums > K:
        break

output = [ [k,v] for k,v in list(dicts.items())]

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

ans=0
for i in range(len(temp)-1):
    if temp[i][1] < K <= temp[i+1][1]:
        ans=temp[i+1][0]
        break

print(ans)

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

def two_int():
    N, K = list(map(int, input().split()))
    return N,K

def one_int():
    return int(eval(input()))

def one_str():
    return eval(input())

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

from collections import defaultdict


N,K = two_int()


query = []
for i in range(N):
    query.append(two_int() )

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

ans=0
sums=0
for q in query:
    if sums < K <= sums+q[1]:
        ans=q[0]
        break
    
    sums += q[1]

print(ans)
# Original solution
N, K = list(map(int, input().split()))

buff = []
a = []
b = []
for i in range(N):
    _a, _b = list(map(int, input().split()))
    a.append(_a)
    b.append(_b)
    buff += [_a]*_b


buff = sorted(buff)
print((buff[K-1]))




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

buff = []
a = []
for i in range(N):
    _a, _b = list(map(int, input().split()))
    buff += [_a]*_b


buff = sorted(buff)
print((buff[K-1]))
# Original solution
N, K = list(map(int, input().split()))

buff = []
a = []
ans = 0
b = 0
for i in range(N):
    _a, _b = list(map(int, input().split()))
    b += _b
    a.append((_a, _b))
    # if b >= K and ans == 0:
    #     ans = _a
    # buff += [_a]*_b


a = sorted(a)

for i in range(N):
    buff += [a[i][0]] * a[i][1]

# buff = sorted(buff)
print((buff[K-1]))


# print(ans)


# Optimized solution
amax = 100000
cnt = [0 for i in range(amax+1)]


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

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


for ans in range(1, amax+1):
    if K <= cnt[ans]:
        print(ans)
        break
    K -= cnt[ans]
# Original solution
N,K = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ 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 _ in range(N)]

ab.sort(key = lambda x:x[0])
idx = 0
i = 0
while True:
    if idx + ab[i][1] > K-1:
        ans = ab[i][0]
        break
    else:
        idx += ab[i][1]
    i += 1
    


print(ans)
# Original solution
n, k = list(map(int, input().split()))
li = []
for i in range(n):
    a, b = list(map(int, input().split()))
    for j in range(b):
        li.append(a)
li.sort()
print((li[k-1]))

# Optimized solution
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)
# Original solution
from collections import Counter
n, k = list(map(int, input().split()))

c = Counter()
for _ in range(n):
    a, b = list(map(int, input().split()))
    c[a] += b
c = sorted(list(c.items()), key=lambda x: x[0])

for i, v in c:
    k -= v
    if k <= 0:
        print(i)
        exit()

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

bucket = [0] * (10 ** 5 + 1)
for _ in range(N):
    a, b = list(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)
        exit()
# Original solution
n,k = list(map(int, input().split()))

ret = []

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

ret.sort()

print((ret[k-1]))


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

ret = {}

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

for i in sorted(ret.keys()):
    k -= ret[i]
    if k <= 0:
        print(i)
        break
# Original solution
N,K = list(map(int,input().split()))
tmp=[]
for i in range(N):
    a_i,b_i=list(map(int,input().split()))
    tmp += [a_i]*b_i

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

# Optimized solution
N,K = list(map(int,input().split()))
tmp=[]
for i in range(N):
    a_i,b_i=list(map(int,input().split()))
    tmp.append([a_i,b_i])

tmp.sort(key=lambda x:x[0])
for t in tmp:
    K -= t[1]
    if K<=0:
        print((t[0]))
        break
# Original solution
#ABC061C
N, K = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
    for _ in range(ab[i][1]):
        ans.append(ab[i][0])
ans.sort()
print((ans[K-1]))

# Optimized solution
#ABC061C
import sys
N, K = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ab.sort()
for a, b in ab:
    now += b
    if now >= K:
            print(a)
            sys.exit()
# Original solution
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
AB = []
for i in range(N):
    a, b = stdin.readline().rstrip().split()
    for j in range(int(b)):
        AB.append(int(a))
AB.sort()
print((AB[K-1]))

# Optimized solution
from sys import exit, stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
AB.sort(key=lambda ab:ab[0])
total_index = 0
for ab in AB:
    total_index += ab[1]
    if total_index >= K:
        print((ab[0]))
        exit()
# Original solution
n,k=list(map(int,input().split()))
a,b=list(map(int,input().split()))
s=[]
s+=[a]*b
for i in range(n-1):
  a,b=list(map(int,input().split()))
  if a>s[-1] and len(s)>k:
    continue
  s+=[a]*b
  s=sorted(s)[:k]
print((s[k-1]))

# Optimized solution
n,k=list(map(int,input().split()))
d=[0]*(10**5+1)
for i in range(n):
  a,b=list(map(int,input().split()))
  d[a]+=b
for i in range(10**5+1):
  if d[i]>=k:
    print(i)
    break
  else:k-=d[i]
# Original solution
N,K =list(map(int,input().split()))
result = []
for i in range(N):
  a,b = list(map(int,input().split()))
  result +=[a]*b
result.sort()
print((result[K-1]))

# Optimized solution
N,K =list(map(int,input().split()))
result = [0]*(10**5+1)
for i in range(N):
  a,b = list(map(int,input().split()))
  result[a] += b
count = 0
for j in range(len(result)):
  count += result[j]
  if count >= K:
    print(j)
    break
# Original solution
from collections import Counter
N, K = list(map(int, input().split()))
C = Counter()
for _ in range(N):
    a, b = list(map(int, input().split()))
    C += {a: b}
# print(C)
L = list(C.keys())
L.sort()
i = 0
ct = C[L[0]]
while ct < K:
    i += 1
    ct += C[L[i]]
print((L[i]))


# Optimized solution
N, K = list(map(int, input().split()))
C = [0]*(10**5+1)
S=set()
for _ in range(N):
    a, b = list(map(int, input().split()))
    C[a] += b
    S.add(a)

L = list(S)
L.sort()
i = 0
ct = C[L[0]]
while ct < K:
    i += 1
    ct += C[L[i]]
print((L[i]))
# Original 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:
        print(a)
        exit()


# Optimized solution
n, k = list(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:
        print(a)
        exit()
# Original solution
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = sorted([list(map(int, input().rstrip('\n').split())) for _ in range(n)])
    t = 0
    for a, b in ab:
        t += b
        if t >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()


# Optimized solution
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()
# Original solution
N, K = list(map(int, input().split()))
a = []
for i in range(N):
    x, y = list(map(int, input().split()))
    for j in range(y):
        a.append(x)
a.sort()

print((a[K - 1]))

# Optimized solution
N, K = list(map(int, input().split()))
a = []
b = []
Sum = 0
for i in range(N):
    x, y = list(map(int, input().split()))
    a.append(x)
    b.append(y)
s = [*list(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
# Original solution
import heapq

def solve():
  firstline = input().split(' ')
  N = int(firstline[0])
  K = int(firstline[1])

  heap = []
  for i in range(N) :
    ar = input().split(' ')
    a = int(ar[0])
    b = int(ar[1])
    heapq.heappush(heap, (a, b))

  count = 0
  while len(heap) > 0 :
    t = heapq.heappop(heap)
    count += t[1]
    if (count >= K) : return t[0]
  return -1

if __name__ == '__main__' :
  print(solve())

# Optimized solution
N,K = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(N)]

s = 0
for a,b in sorted(src):
    s += b
    if s >= K:
        print(a)
        break
# Original solution
from collections import Counter
N,K = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(N)]
ctr = Counter()
for a,b in src:
    ctr[a] += b

tmp = 0
for k,v in sorted(ctr.items()):
    tmp += v
    if tmp >= K:
        print(k)
        exit()

# Optimized solution
from collections import Counter
N,K = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(N)]

ctr = Counter()
for a,b in src:
    ctr[a] += b

now = 0
for k,v in sorted(ctr.items()):
    if now + v < K:
        now += v
    else:
        print(k)
        break
# Original solution
def main():
    N, K = list(map(int, input().split()))
    ans = []
    for i in range(N):
        a, b = list(map(int, input().split()))
        for i in range(b):
            ans.append(a)
    sort_ans = sorted(ans)
    print((sort_ans[K-1]))
    
main()

    

# Optimized solution
def main():
    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
    for i in range(10 ** 5 + 1):
        if K <= ans[i]:
            print(i)
            exit()
        else:
            K -= ans[i]
    
main()
# Original solution
n, k = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
ans = [a[i][0] for i in range(n) for _ in range(a[i][1])]
print((sorted(ans)[k-1]))

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


# Optimized solution
from collections import Counter
N, K = list(map(int, input().split()))
c = Counter()
for _ in range(N):
    a, b = list(map(int, input().split()))
    c[a] += b
for item in sorted(list(c.items()), key=lambda x: x[0]):
    if item[1] >= K:
        print((item[0]))
        break
    else:
        K -= item[1]
# Original solution
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)
print((sorted(l)[K-1]))

# Optimized solution
N, K = list(map(int, input().split()))
l = [0 for i in range(100001)]
num_count = 0
n = 0
for j in range(N):
    a, b = list(map(int, input().split()))
    l[a] += b
for k in l:
    num_count += k
    if num_count >= K:
        print(n)
        break
    else:
        n += 1
# 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()))
arr = []
for _ in range(n):
    a,b = list(map(int,input().split()))
    arr.append([a,b])
arr.sort()
for i in arr:
    k -= i[1]
    if k <= 0:
        print((i[0]))
        break
# Original solution
from collections import deque
n,k=list(map(int,input().split()))
ints=[list(map(int,input().split())) for _ in range(n)]
d=deque()
for x in ints:
  d.extend([x[0]]*x[1])
ans=sorted(list(d))
print((ans[k-1]))

# Optimized solution
import sys
rl=sys.stdin.readline

def main():
    n,k=list(map(int,rl().strip().split()))
    ints=[list(map(int,rl().strip().split())) for _ in range(n)]
    ints.sort(key=lambda e:e[0])
    s=0
    for e in ints:
        s+=e[1]
        if s>=k:
            print((e[0]))
            break

if __name__=='__main__':
    main()
# Original solution
N,K=list(map(int,input().split()))
A=[]
C=[]
for i in range(N):
    a,b=list(map(int,input().split()))
    T=[a,b]
    A.append(T)
A.sort()    
for i in range(N):
    if len(C)>K:
        break
    for j in range(A[i][1]):
        C.append(A[i][0])
        if len(C)>K:
            break      
print((C[K-1]))

# Optimized solution
N,K=list(map(int,input().split()))
A=[]
C=[]
for i in range(N):
    a,b=list(map(int,input().split()))
    T=[a,b]
    A.append(T)
A.sort()
counter=0
for i in range(N):
     counter+=A[i][1]
     if counter>=K:
         counter=i
         break   
print((A[counter][0]))
# 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)
ans.sort()
print((ans[K-1]))

# Optimized solution
N,K = list(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]))
# Original solution
from sys import stdin
from operator import itemgetter


def main():
    lines = stdin.readlines()
    N, K = list(map(int, lines[0].split()))
    abn = [[int(abi) for abi in line.split()] for line in lines[1:]]
    abn.sort(key=itemgetter(0))
    cnt = 0
    for ai, bi in abn:
        cnt += bi
        if K <= cnt:
            print(ai)
            break
    return


main()


# Optimized solution
from sys import stdin


def main():
    lines = stdin.readlines()
    N, K = list(map(int, lines[0].split()))
    bn = [0] * (int(1e5) + 1)
    for line in lines[1:]:
        ai, bi = list(map(int, line.split()))
        bn[ai] += bi
    cnt = 0
    for ai, bi in enumerate(bn):
        cnt += bi
        if K <= cnt:
            print(ai)
            break
    return


main()
# Original solution
N,K = list(map(int,input().split()))
numarray = list()
for i in range(N):
    a,b = list(map(int,input().split()))
    numarray.extend([a]*b)
# print(numarray)
numarray.sort()
print((numarray[K-1]))

# Optimized solution
from itertools import chain
N,K = list(map(int,input().split()))
num_bool = [0]*(10**5)
numarray_ind = list()

for i in range(N):
    a,b = list(map(int,input().split()))
    num_bool[a-1] += b
# print(num_bool)
sum_count = 0
k=1
for i in range(10**5):
    sum_count += num_bool[i]
    if(sum_count >= K):
        break
    k+=1
print(k)
# Original solution
N, K = list(map(int, input().split()))
nums = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    nums += [a] * b
nums.sort()
print((nums[K - 1]))

# Optimized solution
N, K = list(map(int, input().split()))
nums = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    nums.append([a, b])
cnt = 0
nums.sort()
for num in nums:
    cnt += num[1]
    if cnt >= K:
        print((num[0]))
        break