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

A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])

cnt = 0

pay = 0

for i in range(N):

    if cnt+A[i][1]<=M:

        pay += A[i][0]*A[i][1]

        cnt += A[i][1]

    else:

        m = M-cnt

        pay += A[i][0]*m

        break

print(pay)        
N,M = list(map(int,input().split()))

A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])

cnt = 0

cost = 0

for i in range(N):

    a,b = A[i]

    if cnt+b<=M:

        cnt += b

        cost += a*b

    else:

        d = M-cnt

        cost += a*d

        break

print(cost)
N, M = list(map(int, input().split()))
A = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
cnt = 0
pay = 0
for i in range(N):
    if cnt + A[i][1] <= M:
        pay += A[i][0] * A[i][1]
        cnt += A[i][1]
    else:
        m = M - cnt
        pay += A[i][0] * m
        break
print(pay)

N, M = list(map(int, input().split()))
A = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
cnt = 0
cost = 0
for i in range(N):
    a, b = A[i]
    if cnt + b <= M:
        cnt += b
        cost += a * b
    else:
        d = M - cnt
        cost += a * d
        break
print(cost)

-pay = 0 +cost = 0 -    if cnt + A[i][1] <= M: -        pay += A[i][0] * A[i][1] -        cnt += A[i][1] +    a, b = A[i] +    if cnt + b <= M: +        cnt += b +        cost += a * b -        m = M - cnt -        pay += A[i][0] * m +        d = M - cnt +        cost += a * d -print(pay) +print(cost)