Matrix#2311

Matrix

1 second
256 megabytes
Very hard

You are given an n \times n matrix of integers. Your task is to identify a set of coordinates (k_i, l_i) such that each row index k_i and each column index l_i is used exactly once. The goal is to minimize the sum of the elements at these selected coordinates.

Input

The input begins with a single integer (1 \leq n \leq 239). The next lines each contain integers. Each integer in the matrix is within the range -10^6 to 10^6.

Output

The output should start with a single line containing the minimized sum. Following this, output lines, each containing a pair of numbers representing the selected cell coordinates, with the row number listed first.

Examples

Example 1

Loading
Loading