_ = eval(input())

MOD = 10**9 + 7

ans = b = 0

for a in map(int, input().split()):

    ans += a * b

    ans %= MOD

    b += a

print(ans)

_ = eval(input())

ans = b = 0

for a in map(int, input().split()):

    ans += a * b

    b += a

print((ans % (10**9 + 7)))

_ = eval(input())
MOD = 10**9 + 7
ans = b = 0
for a in map(int, input().split()):
    ans += a * b
    ans %= MOD
    b += a
print(ans)

_ = eval(input())
ans = b = 0
for a in map(int, input().split()):
    ans += a * b
    b += a
print((ans % (10**9 + 7)))

-MOD = 10**9 + 7 -    ans %= MOD -print(ans) +print((ans % (10**9 + 7)))