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

AB = list(list(map(int,input().split()))for i in range(N))

AB.sort()

ans = 0

while M > 0:

    A,B = AB.pop(0)

    ans += A*B

    M -= B

ans += M*A

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

AB = list(list(map(int,input().split()))for i in range(N))

AB.sort()

ans = 0

i = 0

while M > 0:

    A,B = AB[i]

    ans += A*B

    M -= B

    i+=1

ans += M*A

print(ans)
N, M = list(map(int, input().split()))
AB = list(list(map(int, input().split())) for i in range(N))
AB.sort()
ans = 0
while M > 0:
    A, B = AB.pop(0)
    ans += A * B
    M -= B
ans += M * A
print(ans)

N, M = list(map(int, input().split()))
AB = list(list(map(int, input().split())) for i in range(N))
AB.sort()
ans = 0
i = 0
while M > 0:
    A, B = AB[i]
    ans += A * B
    M -= B
    i += 1
ans += M * A
print(ans)

+i = 0 -    A, B = AB.pop(0) +    A, B = AB[i] +    i += 1