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

AB = []

for i in range(n):

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

    AB.append((a, b))

AB.sort()



ans = 0

for i in range(n):

    a, b = AB[i]

    if b >= m:

        ans += a*m

        break

    else:

        ans += a*b

    m -= b

print(ans)

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

AB = []

for i in range(n):

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

    AB.append((a, b))



AB.sort()

ans = 0

for a, b in AB:

    if b <= m:

        ans += a*b

        m -= b

    else:

        ans += a*m

        m = 0

    if m == 0:

        break

print(ans)

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

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

-for i in range(n): -    a, b = AB[i] -    if b >= m: +for a, b in AB: +    if b <= m: +        ans += a * b +        m -= b +    else: +        m = 0 +    if m == 0: -    else: -        ans += a * b -    m -= b