# Arup Guha
# 2/26/2026
# Solution to 2026 COP 4516 Team Final Contest Problem C: Airport Charging Stations

# Process cases.
nC = int(input())
for loop in range(nC):

    # Get number of stations and time limit.
    toks = input().split()
    n = int(toks[0])
    t = int(toks[1])

    # Just go to one station, take best answer.
    res = 0
    for i in range(n):
        toks = input().split()
        x = int(toks[0])
        p = int(toks[1])
        res = max(res, (t-2*x)*p)

    # Ta da!
    print(res)
        
