
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 len
# ---------------------------------------------------------------- */
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
tree.append([0,0])		# Add dummy tree at position (0,0)
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

pp.pp(tree)
for i in range(len(tree)):
    d = tree[i][0]+1                    # down pos  d = tree[i][0]+1
    print("+++++ d = ", d)

    for j in range( len(tree) ):
        r = tree[j][1]+1                # right pos r = 1, 2, ..., N-1
        print("+++++++++ r = ", r)

        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 ( not isSolution ):
                break

            if ( isSolution ):
                if ( currlen > len_best ):
                    d_best,r_best,len_best = d, r, currlen
                    print("********************* new best: ", len_best)

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

