def calculate_waste_day(r, day, raw_material_used):
    if day == 4:
        return 2 * raw_material_used - 1
    else:
        return 2 * calculate_waste_day(r, day - 1, raw_material_used) - (raw_material_used if day % 2 == 0 else 0)
def main():
    n, m = map(int, input().split())
    r = float(input())
    data = [tuple(map(int, input().split())) for _ in range(n)]
    inspection_days = list(map(int, input().split))
    waste_dict = {4: 2 * data[0][1] - 1}
    for i in range(1, n):
        day, raw_material_used = data[i]
        waste_dict[day] = calculate_waste_day(r, day, raw_material_used)
    for day in inspection_days:
        print(waste_dict[day])
if _name_=="__main":
    main()
