
import pprint as pp


def min(x,y):
    if ( x < y ):
        return x
    else:
        return y


# ----------------------------------------------------------------
# isInsidePool( i, d, r, currlen ): check if tree i is inside
#                               pool at (d,r) with lenght currlen
# ---------------------------------------------------------------- */
def isInsidePool(tree, d, r, currlen):
    if ( d <= tree[0] and tree[0] < d+currlen and
         r <= tree[1] and tree[1] < r+currlen ):
        return True
    else:
        return False


N = int( input() )
print("GridSize N = ", N)

T = int( input() )
print("# Trees T = ", T);

# int tree[1000000][2]  =  [ [1 2], [2, 3], ... ]
tree = list();  # 2 dim array
for i in range( T ):
    nextTreeCoord = [ int(x) for x in input().split() ]
    tree.append( nextTreeCoord )

print("Trees: ", end="")
pp.pp(tree)

# ====================================================
# Brute force search alg
# ====================================================

# The best solution so far
d_best = -1
r_best = -1
len_best = 0

for d in range(1,N):        # down pos  d = 1, 2, ..., N-1
    for r in range(1,N):    # right pos r = 1, 2, ..., N-1
        maxLen = min( N-d+1, N-r+1 )        # max len for a pool before hits an edge
        for currlen in range(1, maxLen):
            isSolution = True                # Assume no tree inside pool (d,r,currlen)

            for k in tree:
                if ( isInsidePool(k, d, r, currlen) ):
                    isSolution = False
                    break

            if ( isSolution ):
                if ( currlen > len_best ):
                    d_best,r_best,len_best = d, r, currlen

print("Answer: ", len_best)
print("Upper left corner = (", d_best, ",", r_best, ")")

