#CCBCHBON0000031. Thoát hai vòng bằng cờ (Exit Two Loops With a Flag)

Thoát hai vòng bằng cờ (Exit Two Loops With a Flag)

Exit Two Loops With a Flag

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Read an r-by-c integer grid in row-major order. Print the 1-based row and column of the first negative value, or -1 -1 if absent. No matrix allocation is needed.

Input

Two integers r,c, followed by exactly r*c integers in [-100,100], row-major; 1<=r,c<=100.

Output

Print two 1-based indices separated by a space.

Subtasks

  • Subtask 1 (20%): 1≤r,c≤41\le r,c\le 4; −100≤aij≤100-100\le a_{ij}\le100.

  • Subtask 2 (30%): 1≤r,c≤251\le r,c\le 25; −100≤aij≤100-100\le a_{ij}\le100.

  • Subtask 3 (50%): 1≤r,c≤1001\le r,c\le 100; −100≤aij≤100-100\le a_{ij}\le100.

Examples

Example 1

Input:

2 2
1 2
-3 4

Output:

2 1

Explanation:

Indices start at 1 and are checked row-major; no negative means -1 -1. Result: 2 1.

Example 2

Input:

1 3
1 0 2

Output:

-1 -1

Explanation:

Indices start at 1 and are checked row-major; no negative means -1 -1. Result: -1 -1.

Example 3

Input:

2 2
1 2
3 -4

Output:

2 2

Explanation:

Indices start at 1 and are checked row-major; no negative means -1 -1. Result: 2 2.