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

ab=[]

ans=0

for i in range(n):

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

  ab.append([a,b])

ab.sort()

for a,b in ab:

  t=min(b,m)

  ans+=t*a

  m-=t

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

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

ab.sort(key=lambda x: x[0])

ans=0

for a,b in ab:

  if m>=b:

    m-=b

    ans+=b*a

  else:

    ans+=a*m

    break

print(ans)

n, m = list(map(int, input().split()))
ab = []
ans = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    ab.append([a, b])
ab.sort()
for a, b in ab:
    t = min(b, m)
    ans += t * a
    m -= t
print(ans)

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

-ab = [] +ab = [list(map(int, input().split())) for _ in range(n)] +ab.sort(key=lambda x: x[0]) -for i in range(n): -    a, b = list(map(int, input().split())) -    ab.append([a, b]) -ab.sort() -    t = min(b, m) -    ans += t * a -    m -= t +    if m >= b: +        m -= b +        ans += b * a +    else: +        ans += a * m +        break