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

A = []

B = []

for i in range(n):

    x, y = list(map(int, input().split()))

    A.append(x)

    B.append(y)



ans = 0

for price, amount in sorted(zip(A, B)):

    ans += price * min(m, amount)

    m -= amount

    if m <= 0:

        break

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



ans = 0

for price, amount in sorted(zip(l[::2], l[1::2])):

    ans += price * min(m, amount)

    m -= amount

    if m <= 0:

        break

print(ans)
n, m = list(map(int, input().split()))
A = []
B = []
for i in range(n):
    x, y = list(map(int, input().split()))
    A.append(x)
    B.append(y)
ans = 0
for price, amount in sorted(zip(A, B)):
    ans += price * min(m, amount)
    m -= amount
    if m <= 0:
        break
print(ans)

n, m, *l = list(map(int, open(0).read().split()))
ans = 0
for price, amount in sorted(zip(l[::2], l[1::2])):
    ans += price * min(m, amount)
    m -= amount
    if m <= 0:
        break
print(ans)

-n, m = list(map(int, input().split())) -A = [] -B = [] -for i in range(n): -    x, y = list(map(int, input().split())) -    A.append(x) -    B.append(y) +n, m, *l = list(map(int, open(0).read().split())) -for price, amount in sorted(zip(A, B)): +for price, amount in sorted(zip(l[::2], l[1::2])):