for _ in range(input()) : raw_input() m = max(map(int, raw_input().split())) c, d, s = map(int, raw_input().split()) print (c - 1) * m