n = int(eval(input()))

mod = int(1e9+7)

ans, t = 0, 0

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

    ans = (ans+a*t) % mod

    t = (t + a) % mod



print(ans)

n = int(eval(input()))

mod = int(1e9+7)

ans, t = 0, 0

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

    ans = (ans+a*t) % mod

    t += a



print(ans)

n = int(eval(input()))
mod = int(1e9 + 7)
ans, t = 0, 0
for a in list(map(int, input().split())):
    ans = (ans + a * t) % mod
    t = (t + a) % mod
print(ans)

n = int(eval(input()))
mod = int(1e9 + 7)
ans, t = 0, 0
for a in list(map(int, input().split())):
    ans = (ans + a * t) % mod
    t += a
print(ans)

-    t = (t + a) % mod +    t += a