PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000100. Tìm đỉnh trong ma trận (Find a Peak Element II)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tìm đỉnh trong ma trận (Find a Peak Element II)

Find a Peak Element II

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

An entry in an m×nm\times n matrix is a peak if it is strictly greater than each existing orthogonally adjacent entry; outside the matrix the value is −1-1. Find any zero-based peak coordinate, given that orthogonal neighbors are unequal.

Input

The first line contains m,nm,n. The next mm lines contain nn integers each.

Output

Print two integers r,cr,c: the zero-based row and column of any valid peak.

Subtasks

  • Subtask 1 (20 points): 1≤m,n≤101\le m,n\le 10; 1≤ai,j≤1051\le a_{i,j}\le10^5; orthogonally adjacent entries are unequal.
  • Subtask 2 (30 points): 1≤m,n≤801\le m,n\le 80; 1≤ai,j≤1051\le a_{i,j}\le10^5; orthogonally adjacent entries are unequal.
  • Subtask 3 (50 points): 1≤m,n≤5001\le m,n\le 500; 1≤ai,j≤1051\le a_{i,j}\le10^5; orthogonally adjacent entries are unequal.

Examples

Input

2 2
1 4
3 2

Output

1 0

Explanation

Cell (1,0)(1,0) has value 33, greater than the adjacent values 11 and 22, as well as the outer value −1-1. Thus 1 0 is valid; 0 1 would also be valid.