n = int(eval(input()))

a = [i+1 for i in range(n)]

b = [1]

for i in range(1,n):

  b.append(b[-1] + a[i])

c = [0]

for i in range(n-1):

  c.append(c[-1]+b[i])

#print(a)

#print(b)

#print(c)

ans = b[-1] + c[-1]

for _ in range(n-1):

  xy = list(map(int,input().split()))

  xy.sort()

  x,y = xy

  ans -= x * (n+1-y)

print(ans)
n = int(eval(input()))

ans = n*(n+1)*(n+2)//6

for i in range(n-1):

  xy = list(map(int,input().split()))

  ans -= min(xy) * (n+1-max(xy))

print(ans)
n = int(eval(input()))
a = [i + 1 for i in range(n)]
b = [1]
for i in range(1, n):
    b.append(b[-1] + a[i])
c = [0]
for i in range(n - 1):
    c.append(c[-1] + b[i])
# print(a)
# print(b)
# print(c)
ans = b[-1] + c[-1]
for _ in range(n - 1):
    xy = list(map(int, input().split()))
    xy.sort()
    x, y = xy
    ans -= x * (n + 1 - y)
print(ans)

n = int(eval(input()))
ans = n * (n + 1) * (n + 2) // 6
for i in range(n - 1):
    xy = list(map(int, input().split()))
    ans -= min(xy) * (n + 1 - max(xy))
print(ans)

-a = [i + 1 for i in range(n)] -b = [1] -for i in range(1, n): -    b.append(b[-1] + a[i]) -c = [0] +ans = n * (n + 1) * (n + 2) // 6 -    c.append(c[-1] + b[i]) -# print(a) -# print(b) -# print(c) -ans = b[-1] + c[-1] -for _ in range(n - 1): -    xy.sort() -    x, y = xy -    ans -= x * (n + 1 - y) +    ans -= min(xy) * (n + 1 - max(xy))