li_a = []

ans = 0

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

for i in range(N):

    a,b = list(map(int,input().split()))

    li_a +=[[a,b]]

li_a.sort()

for i in range(N):

    if li_a[i][-1] >= M:

        ans += M * li_a[i][0]

        print(ans)

        break

    else:

        ans += li_a[i][-1] * li_a[i][0]

        M -= li_a[i][-1]







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

ab = [0] * n

ans = 0

for i in range(n):

    a,b = list(map(int,input().split()))

    ab[i]= (a,b)

ab.sort()



for i in range(n):

    if m > ab[i][1]:

        m -= ab[i][1]

        ans += ab[i][0] * ab[i][1]

    else:

        ans += ab[i][0] * m

        break



print(ans)
li_a = []
ans = 0
N, M = list(map(int, input().split()))
for i in range(N):
    a, b = list(map(int, input().split()))
    li_a += [[a, b]]
li_a.sort()
for i in range(N):
    if li_a[i][-1] >= M:
        ans += M * li_a[i][0]
        print(ans)
        break
    else:
        ans += li_a[i][-1] * li_a[i][0]
        M -= li_a[i][-1]

n, m = list(map(int, input().split()))
ab = [0] * n
ans = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    ab[i] = (a, b)
ab.sort()
for i in range(n):
    if m > ab[i][1]:
        m -= ab[i][1]
        ans += ab[i][0] * ab[i][1]
    else:
        ans += ab[i][0] * m
        break
print(ans)

-li_a = [] +n, m = list(map(int, input().split())) +ab = [0] * n -N, M = list(map(int, input().split())) -for i in range(N): +for i in range(n): -    li_a += [[a, b]] -li_a.sort() -for i in range(N): -    if li_a[i][-1] >= M: -        ans += M * li_a[i][0] -        print(ans) +    ab[i] = (a, b) +ab.sort() +for i in range(n): +    if m > ab[i][1]: +        m -= ab[i][1] +        ans += ab[i][0] * ab[i][1] +    else: +        ans += ab[i][0] * m -    else: -        ans += li_a[i][-1] * li_a[i][0] -        M -= li_a[i][-1] +print(ans)