시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 256 MB111100.000%

문제

In a square matrix with $n$ rows, all elements are integers. You can swap two elements of the matrix at one step. Find out the minimal number of steps necessary to obtain a symmetric matrix from the initial one. A symmetric matrix is a matrix with the same element at the intersection of the $i$th row and $j$th column as that at the intersection of the $j$th row and the $i$th column for any $i$, $j$.

It is guaranteed that in this matrix, $n$ elements occur only once, and each of the rest occurs twice.

입력

The first line of the input file contains an integer $n$ --- the number of rows in the matrix ($1\le n \le 500$). The following $n$ lines describe the rows of the matrix. Each of them contains $n$ space-separated integers, which are not greater than $10^9$ in absolute value.

출력

In the first line of the output file, print a single integer $m$ --- the minimal number of steps to obtain a symmetric matrix. Next, print an example of $m$ such steps. For the $i$th step, print four integers $a_i$, $b_i$, $c_i$, $d_i$ into a separate line, which mean that the element located in the $a_i$th row and the $b_i$th column must be swapped with the element in the $c_i$th row and the $d_i$th column.

예제 입력 1

2
1 2
3 1

예제 출력 1

2
1 1 1 2
2 1 2 2

예제 입력 2

3
1 4 -3
4 2 5
6 6 5

예제 출력 2

2
3 3 3 2
3 3 1 3