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

ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort()

money = 0

drink = 0

for a,b in ab:

  money += a*b

  drink += b

  if drink >= m:

    money -= (drink-m) * a

    break

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

ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort()

money = 0

drink = 0

for a,b in ab:

    if drink+b <= m:

        drink += b

        money += a*b

    else:

        money += (m-drink) * a

        drink = m

    if drink == m: break

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

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
money = 0
drink = 0
for a, b in ab:
    if drink + b <= m:
        drink += b
        money += a * b
    else:
        money += (m - drink) * a
        drink = m
    if drink == m:
        break
print(money)

-    money += a * b -    drink += b -    if drink >= m: -        money -= (drink - m) * a +    if drink + b <= m: +        drink += b +        money += a * b +    else: +        money += (m - drink) * a +        drink = m +    if drink == m: