I=lambda:list(map(int,input().split()));n,m=I();c=0

for a,b in sorted(I()for _ in[0]*n):c+=a*min(m,b);m=max(0,m-b)

print(c)
n,m,*t=list(map(int,open(0).read().split()));c=0

for a,b in sorted(zip(t[::2],t[1::2])):c+=a*min(m,b);m=max(0,m-b)

print(c)
I = lambda: list(map(int, input().split()))
n, m = I()
c = 0
for a, b in sorted(I() for _ in [0] * n):
    c += a * min(m, b)
    m = max(0, m - b)
print(c)

n, m, *t = list(map(int, open(0).read().split()))
c = 0
for a, b in sorted(zip(t[::2], t[1::2])):
    c += a * min(m, b)
    m = max(0, m - b)
print(c)

-I = lambda: list(map(int, input().split())) -n, m = I() +n, m, *t = list(map(int, open(0).read().split())) -for a, b in sorted(I() for _ in [0] * n): +for a, b in sorted(zip(t[::2], t[1::2])):