#!/bin/python3

import math
import os
import random
import re
import sys


# Complete the diagonalDifference function below.
def diagonalDifference(arr):
    dia1 = dia2 = 0
    n = len(arr) - 1
    for i in range(0, len(arr)):
        dia1 = dia1 + arr[i][i]
        dia2 = dia2 + arr[n - i][i]
        print("%d %d\n"%(n-i, i))
    return abs(abs(dia1) - abs(dia2))


if __name__ == '__main__':
    # fptr = open(os.environ['OUTPUT_PATH'], 'w')

    n = int(input())

    arr = []

    for _ in range(n):
        arr.append(list(map(int, input().rstrip().split())))

    result = diagonalDifference(arr)
    print(result)

    # fptr.write(str(result) + '\n')

    # fptr.close()