6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

def compute123(row):
    n = len(row)
    sum123 = [row[i] * (i + 1) for i in range(n)]
    _sum = 0
    for i in range(n-1, -1, -1):
        _sum += sum123[i]
        sum123[i] = _sum
    return sum123

def compute321(row):
    n = len(row)
    sum321 = [row[i] * (n - i) for i in range(n)]
    _sum = 0
    for i in range(n-1, -1, -1):
        _sum += sum321[i]
        sum321[i] = _sum
    return sum321

def compute111(row):
    n = len(row)
    sum111 = [e for e in row]
    _sum = 0
    for i in range(n-1, -1, -1):
        _sum += sum111[i]
        sum111[i] = _sum
    return sum111
    

    

def main():
    n = int(input())
    row1 = [int(c) for c in input().split()]
    row2 = [int(c) for c in input().split()]
    grid = [row1, row2]

    sum123_1, sum123_2 = compute123(row1), compute123(row2)
    sum321_1, sum321_2 = compute321(row1), compute321(row2)
    sum111_1, sum111_2 = compute111(row1), compute111(row2)
    
    print(sum123_1, sum123_2)
    print(sum321_1, sum321_2)
    print(sum111_1, sum111_2)


if __name__ == '__main__':
    main()
