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



print((m*(m-1)//2 + n*(n-1)//2))

print((sum([int(i)*(int(i)-1)//2 for i in input().split()])))

n, m = list(map(int, input().split()))
print((m * (m - 1) // 2 + n * (n - 1) // 2))

print((sum([int(i) * (int(i) - 1) // 2 for i in input().split()])))

-n, m = list(map(int, input().split())) -print((m * (m - 1) // 2 + n * (n - 1) // 2)) +print((sum([int(i) * (int(i) - 1) // 2 for i in input().split()])))