CodeEff/ECCO huggingface dataset:
# Original solution
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    s = S()
    d = deque(s)
    ans = 0

    # print(d)

    while len(d) > 1:
        if d[0] == d[-1]:
            d.popleft()
            d.pop()
        elif d[0] == 'x':
            d.append('x')
            ans += 1
        elif d[-1] == 'x':
            d.appendleft('x')
            ans += 1
        else:
            print(-1)
            return

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    s = S()
    d = deque(s)
    ans = 0

    while len(d) > 1:
        l = d.popleft()
        r = d.pop()

        if l == r:
            continue
        elif l == 'x':
            ans += 1
            d.append(r)
        elif r == 'x':
            ans += 1
            d.appendleft(l)
        else:
            print(-1)
            return

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
N, K = list(map(int, input().split()))
arr = [list(map(int, input().split())) for i in range(N)]
arr.sort()
 
n = 0
for i in range(N):
	n += arr[i][1]
	if n >= K:
		print((arr[i][0]))
		break

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

cnt=0
for i in range(n):
  cnt+=li[i][1]
  if cnt>=k:
    print((li[i][0]))
    break
# Original solution
def main():
    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(key=lambda x: x[0])

    c = 0
    for a, b in AB:
        if c <= K <= c + b:
            ans = a
            break
        c += b
    print(ans)


if __name__ == "__main__":
    main()

# Optimized solution
def main():
    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(key=lambda x: x[0])

    c = 0
    for a, b in AB:
        if K <= c + b:
            ans = a
            break
        c += b
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
from collections import deque
n, k = list(map(int, input().split()))
d = deque()
for _ in range(n):
    a, b = list(map(int, input().split()))
    d.append([a, b])
x = sorted(list(d))
for i in range(n):
    k -= x[i][1]
    if k < 1:
        print((x[i][0]))
        break


# Optimized solution
n, k = list(map(int, input().split()))
x = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    x.append([a, b])
x = sorted(x)
for i in range(n):
    k -= x[i][1]
    if k < 1:
        print((x[i][0]))
        break
# Original solution
n,k=list(map(int,input().split()))
s=[]
for i in range(n):
    a,b=list(map(int,input().split()))
    s.extend([a for _ in range(b)])
s.sort()
print((s[k-1]))

# Optimized solution
import bisect
n,k=list(map(int,input().split()))
s=[0 for _ in range((10**5)+1)]
maxa=0
for i in range(n):
    a,b=list(map(int,input().split()))
    s[a]+=b
    maxa=max(maxa,a)
s=s[:maxa]
#print(s)
for i in range(1,len(s)):
    s[i]+=s[i-1]
#print(s)
print((bisect.bisect_left(s, k)))
# Original solution
N, K = list(map(int, input().split()))
d = []

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

print((d[K-1]))

# Optimized solution
import bisect

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


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

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print((d[pos][0]))
# Original solution
import bisect

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


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

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print((d[pos][0]))

# Optimized solution
import sys
import bisect

N, K = list(map(int, sys.stdin.readline().split()))
d = []


for i in range(N):
    a, b = list(map(int, sys.stdin.readline().split()))
    d.append([a,b])

d.sort()

l = [0] * N
l[0] = d[0][1]

for i in range(1, N):
    l[i] = d[i][1]+ l[i-1]

pos = bisect.bisect_left(l, K)
print((d[pos][0]))
# Original solution
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N,K=LI()
#AB=[LI() for i in range(N)]

counts={}
l=[]
for i in range(N):
	ab=LI()

	if not counts.get(ab[0]):
		counts[ab[0]]=ab[1]
	else:
		counts[ab[0]]+=ab[1]
	if ab[0] not in l:
		l.append(ab[0])

l.sort()
c=0
for item in l:
	c+=counts.get(item)
	if c>=K:
		print(item)
		exit()


# Optimized solution
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N,K=LI()
A=[]
B=[]
AB=[]
for i in range(N):
	a,b=LI()
	A.append(a)
	B.append(b)
	AB.append([a,b])
A=list(set(A))
A.sort()
counts={}
for a in A:
	counts[a]=0

for ab in AB:
	counts[ab[0]]+=ab[1]
if K<N/2:
	c=0
	for item in A:
		c+=counts.get(item)
		if c>=K:
			print(item)
			exit()
else:
	c=sum(B)
	for item in reversed(A):
		c-=counts.get(item)
		if c<K:
			print(item)
			exit()
# Original solution
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    big_array = []
    for i in range(N):
        big_array += [a[i]]*b[i]
    big_array.sort()
    print((big_array[K-1]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    ab = list(zip(a,b))
    ab.sort(key=lambda x: x[0])
    sumb =0
    123334
    for i in range(N):
        sumb+=ab[i][1]
        if sumb>=K:
            print((ab[i][0]))
            return 
        
    

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()
# Original solution
# coding: utf-8


def add_list(_n):
    _l = []
    for _ in range(_n):
        a, b = list(map(int, input().split()))
        _l.append([a for _ in range(b)])
    return [j for i in _l for j in i]

n, k = list(map(int, input().split()))
l = add_list(n)
l.sort()
print(l[k-1])


# Optimized solution
# coding: utf-8

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

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

for i in range(1, l+1):
    k -= num[i]
    if k <= 0:
        print(i)
        break
# Original solution
n,k=list(map(int,input().split()))
a,b=[],[]
for i in range(n):
    A,B=list(map(int,input().split()))
    b=[A]*B
    a=a+b
a.sort()
print((a[k-1]))

# Optimized solution
n,k=list(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]))
        exit()
# Original solution
N, K = [int(i) for i in input().split()]
L = []
for i in range(N):
  a, b = [int(j) for j in input().split()]
  l = [a]*b
  L.extend(l)
L.sort()
print((L[K-1]))

# Optimized solution
N, K = [int(i) for i in input().split()]
L = []
for i in range(N):
  a, b = [int(j) for j in input().split()]
  L.append([a, b])
L.sort(key=lambda x: x[0])
#print(L)

cnt = 0
for x, y in L:
  cnt += y
  if cnt >= K:
    ans = x
    break
print(ans)
# Original solution
N, K = [int(x) for x in input().split()]
Array = list()
a = 0
b = 0
for i in range(N):
	a, b = [int(x) for x in input().split()]
	Array.extend([a]*b)
	if len(Array) > K:
		Array.sort()
		Array = Array[:K]
	
print((Array[K - 1]))

# Optimized solution
from operator import itemgetter

N, K = [int(x) for x in input().split()]
Array = list()
A = list()
count = 0
ans = 0
for i in range(N):
	A.append([int(x) for x in input().split()])

A.sort(key=itemgetter(0))
for i in range(N):
	count += A[i][1]
	if count >= K:
		ans = A[i][0]
		break
		
print(ans)
# Original solution
N,K=list(map(int,input().split()))
Array=[]
for n in range(0,N):
    a,b=input().split()
    Array+=((a+" ")*int(b)).split()
    Array.sort()
print((int(Array[K-1])))


# Optimized solution
N,K=list(map(int,input().split()))
Array={}
for n in range(0,N):
    a,b=list(map(int,input().split()))
    if a in Array:
        Array[a]+=b
    else:
        Array[a]=b
numbers=sorted(list(Array.keys()))
n=0
k=0
while True:
    k+=Array[numbers[n]]
    if k>=K:
        break
    n+=1
print((numbers[n]))
# Original solution
N, K = list(map(int, input().split()))
seq = []
for i in range(N):
    a, b = list(map(int, input().split()))
    for j in range(b):
        seq.append(a)

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


# Optimized solution
from collections import defaultdict
N, K = list(map(int, input().split()))
seq = defaultdict(lambda: 0) 
for i in range(N):
    a, b = list(map(int, input().split()))
    seq[a] += b

values = list(seq.keys())

values.sort()
ans = 0
for i in range(len(values)):
    K -= seq[values[i]]
    if(K<=0):
        print((values[i]))
        break
# Original solution
if __name__ == '__main__':

	#入力
	N, K  = list(map(int,input().split()))
	lst = []
	for i in range(0,N):
		a, b = list(map(int,input().split()))
		lst.append([a,b])

	ans_lst = []
	for i in range(0,N):
		a = lst[i][0]
		b = lst[i][1]
		for j in range(0,b):
			ans_lst.append(a)

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

# Optimized solution
if __name__ == '__main__':

	#入力
	N, K  = list(map(int,input().split()))
	lst = []
	for i in range(0,N):
		a, b = list(map(int,input().split()))
		lst.append([a,b])

	lst.sort()
	indx = 0

	for i in range(0,N):
		indx += lst[i][1]
		if indx >= K:
			ans = lst[i][0]
			break

	print(ans)
# Original solution
N, K = (int(i) for i in input().split())

L = []
for i in range(N):
    a, b = (int(i) for i in input().split())
    L = L + [a]*b
    if len(L) > K:
        L.sort()
        L = L[:K]
        if L[-1] == 1:
            print((1))
            break
else:
    print((L[-1]))

# Optimized solution
N, K = (int(i) for i in input().split())

D = {}
count = 0
for i in range(N):
    a, b = (int(i) for i in input().split())
    if a in D:
        D[a] += b
    else:
        D[a] = b

else:
    aL = [a for a in list(D.keys())]
    aL.sort()
    for a in aL:
        count += D[a]
        if count >= K:
            print(a)
            break
# Original solution
N, K = list(map(int, input().split()))

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

print((lis[K-1]))

# Optimized solution
N, K = list(map(int, input().split()))
from itertools import accumulate
from bisect import bisect_left

lis = []
lis = [tuple(map(int, input().split())) for i in range(N)]
lis.sort()
Bs = [y for x, y in lis]
cB = list(accumulate(Bs))

print((lis[bisect_left(cB, K)][0]))
# Original solution
n,k=list(map(int,input().split()))
h=[]

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

h=sorted(h)
print((h[k-1]))


# Optimized solution
n,k = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
a.sort()
now = 0
for i in a:
  now += i[1]
  if now >= k:
    print((i[0]))
    break
# Original solution
N,K = list(map(int,input().split()))
temp = []
c,t = K,-1
for i in range(N):
    temp.append(list(map(int,input().split())))
    temp.sort()
while c>0:
    t += 1
    c -= temp[t][1]
print((temp[t][0]))

# Optimized solution
N,K = list(map(int,input().split()))
temp = []
c,t = K,-1
for i in range(N):
    temp.append(list(map(int,input().split())))
temp.sort()
while c>0:
    t += 1
    c -= temp[t][1]
print((temp[t][0]))
# Original solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    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]))
resolve()

# Optimized solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=list(map(int, input().split()))
    l=[list(map(int,input().split())) for i in range(n)]
    l.sort(key=lambda x:x[0])
    kosu=0
    for i in range(n):
        kosu+=l[i][1]
        if kosu>=k:
            print((l[i][0]))
            break
resolve()
# Original solution
n, k = list(map(int, input().split()))
array = []
for i in range(n):
    a, b = list(map(int, input().split()))
    for j in range(b):
        array.append(a)
array.sort()
print((array[k-1]))


# Optimized solution
n, k = list(map(int, input().split()))
number = [[0,0] for i in range(n)]
for i in range(n):
    number[i] = list(map(int, input().split()))
number.sort(key=lambda x:(x[0],x[1]))
count = 0
result = 0
for el in number:
    count += el[1]
    if count >= k:
        result = el[0]
        break
print(result)
# Original solution
from bisect import bisect_left,bisect_right
N,K=list(map(int,input().split()))
table=[]
for i in range(N):
    a,b=list(map(int,input().split()))
    table.append([a,b])
table.sort()
cou=[0]*N
cou[0]=table[0][1]
for i in range(1,N):
    cou[i]=cou[i-1]+table[i][1]
s = bisect_left(cou,K)
print((table[s][0]))

# Optimized solution
N,K=list(map(int,input().split()))
table=[]
for i in range(N):
    a,b=list(map(int,input().split()))
    table.append([a,b])
table.sort()
ans = 0
for x,y in table:
    ans += y
    if ans >=K:
        print(x)
        break
# Original solution
NK = list(map(int,input().split()))
AB = []
for _ in range(NK[0]):
    I = list(map(int, input().split()))
    for _ in range(I[1]):
        AB.append(I[0])
print((sorted(AB)[NK[1]-1]))

# Optimized solution
from operator import itemgetter, attrgetter
NK = list(map(int,input().split()))
AB = sorted([tuple(map(int, input().split())) for _ in range(NK[0])],key = itemgetter(0))
for i,j in AB:
    NK[1] = NK[1] - j
    if NK[1]<=0:
        print(i)
        break
# Original solution
n,k=list(map(int, input().split()))
a=[list(map(int, input().split())) for i in range(n)]
a.sort()
#print(a)
b=[]
for i,j in a:
    b=b+[i]*j
    if len(b)>k:break
print((b[k-1]))

# Optimized solution
n,k=list(map(int, input().split()))
a=[list(map(int, input().split())) for i in range(n)]
a.sort()
#print(a)
b=[]
c=0
for i,j in a:
    k-=j
    c=i
    if k<=0: break
print(c)
# Original solution
# ABC061C - Big Array
import sys
input = sys.stdin.readline

def main():
    n, k = list(map(int, input().rstrip().split()))
    arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
    cur, cnt, ans = 0, 0, 0
    while cnt < k:
        cnt += arr[cur][1]
        ans = arr[cur][0]
        cur += 1
    print(ans)


if __name__ == "__main__":
    main()

# Optimized solution
# ABC061C - Big Array
import sys
input = sys.stdin.readline

def main():
    n, k = list(map(int, input().rstrip().split()))
    arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
    cur, cnt, ans = 0, 0, 0
    for i, j in arr:
        ans = i
        cnt += j
        if cnt >= k:
            break
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
# ABC061C - Big Array
import sys
input = sys.stdin.readline

def main():
    n, k = list(map(int, input().rstrip().split()))
    arr = [list(map(int, input().rstrip().split())) for _ in range(n)]
    memo = [0] * (10 ** 5 + 1)
    for i, j in arr:
        memo[i] += j
    cnt = 0
    for i, j in enumerate(memo):
        cnt += j
        if cnt >= k:
            print(i)
            break


if __name__ == "__main__":
    main()

# Optimized solution
# ABC061C - Big Array
import sys
input = sys.stdin.readline

def main():
    n, k = list(map(int, input().rstrip().split()))
    memo = [0] * (10 ** 5 + 1)
    for _ in range(n):
        i, j = list(map(int, input().rstrip().split()))
        memo[i] += j
    cnt = 0
    for i, j in enumerate(memo):
        cnt += j
        if cnt >= k:
            print(i)
            break


if __name__ == "__main__":
    main()
# Original solution
n, k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
l = []
for x in ab:
    l += [x[0]] * x[1]
print((sorted(l)[k-1]))

# Optimized solution
n, k = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
length = 0
for x in sorted(ab, key=lambda x: x[0]):
    length += x[1]
    if length >= k:
        print((x[0]))
        break
# Original solution
n, k = list(map(int, input().split()))
lst = []
for i in range(n):
    a, b = list(map(int, input().split()))
    for j in range(b):
        lst.extend([a])
lst.sort()
print((lst[k-1]))

# Optimized solution
n, k = list(map(int, input().split()))
dic = {}
lst = []
ans = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    if (a in dic)==False:
        dic[a] = b
        lst.append(a)
    else:
        dic[a] += b
lst.sort()

for i in range(len(dic)):
    if k > (dic[lst[i]] + ans):
        ans += dic[lst[i]]
    else:
        ans = lst[i]
        break
print(ans)
# Original solution
n, k = list(map(int, input().split()))

nums = []
for _ in range(n):
  a, b = list(map(int, input().split()))
  nums.extend([a]*b)
  
sn = sorted(nums)
print((sn[k-1]))


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

nums = []
for _ in range(n):
  ab = list(map(int, input().split()))
  nums.append(ab)
sn = sorted(nums)

i = 0
while k > 0:
  if sn[i][1] < k:
    k -= sn[i][1]
  else:
    print((sn[i][0]))
    break
  i += 1
# Original solution
n, k = list(map(int, input().split()))
c = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    c.extend([a]*b)
c.sort()
print((c[k-1]))

# Optimized solution
n, k = list(map(int, input().split()))
aa = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    aa.append([a, b])
aa.sort()
c = 0
for a, b in aa:
    if c < k:
        c += b
        if c >= k:
            ans = a
            break
print(ans)
# Original solution
from collections import defaultdict

n,k=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
    a,b=list(map(int,input().split()))
    d[a]+=b
l=sorted(d.keys())
cnt=0
for i in l:
    cnt+=d[i]
    if cnt>=k:
        print(i)
        exit()

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

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

d_keys=sorted(d.keys())
cnt=0
for i in d_keys:
  cnt+=d[i]
  if cnt>=k:
    print(i)
    exit()
# Original solution
n,k=list(map(int,input().split()))

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

cnt=0
for i in range(len(l)):
  cnt+=l[i]
  if cnt>=k:
    print((i+1))
    exit()

# Optimized solution
from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))
from bisect import bisect_left

n,k=nii()

l=[]
for i in range(n):
  a,b=nii()
  l.append([a,b])

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

a_l=[]
b_l=[]
for a,b in l:
  a_l.append(a)
  b_l.append(b)

b_rui=[0]
for i in range(1,n+1):
  b_rui.append(b_rui[i-1]+b_l[i-1])
b_rui=b_rui[1:]

inx=bisect_left(b_rui,k)
print((a_l[inx]))
# Original solution
n, k = list(map(int,input().split()))
ans  = []

for i in range(n):
    x, y = list(map(int,input().split()))
    ans += [x]*y

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

# Optimized solution
n, k = list(map(int,input().split()))
ans  = []
x = 0

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

ans.sort()

for l in ans:
    x += l[1]
    if x < k:
        continue
    else:
        print((l[0]))
        exit()
# Original solution
N, K = list(map(int,input().split( )))
l = []
for i in range(N):
	a, b = list(map(int, input().split( )))
	for i in range(b):
		l.append(a)
l.sort()
print((l[K-1]))

# Optimized solution
from collections import defaultdict

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

a = []
b = []

for i in range(N):
	a_i, b_i = list(map(int, input().split( )))
	a.append(a_i)
	b.append(b_i)

d = defaultdict(int)

for i in range(N):
    if a[i] in d:
        d[a[i]] += b[i]
    else:
        d[a[i]] = b[i]

d_sorted = sorted(d.items())

l = 0

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