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

for a,b in sorted(list(f())for _ in range(n)):t=min(b,m);c+=a*t;m-=t

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

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

print(c)
f = lambda: list(map(int, input().split()))
n, m = f()
c = 0
for a, b in sorted(list(f()) for _ in range(n)):
    t = min(b, m)
    c += a * t
    m -= t
print(c)

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

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