The package for this problem was not updated by the problem writer or Codeforces administration after we've upgraded the judging servers. To adjust the time limit constraint, a solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then the value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Young Table

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputYou've got table *a*, consisting of *n* rows, numbered from 1 to *n*. The *i*-th line of table *a* contains *c*_{i} cells, at that for all *i* (1 < *i* ≤ *n*) holds *c*_{i} ≤ *c*_{i - 1}.

Let's denote *s* as the total number of cells of table *a*, that is, . We know that each cell of the table contains a single integer from 1 to *s*, at that all written integers are distinct.

Let's assume that the cells of the *i*-th row of table *a* are numbered from 1 to *c*_{i}, then let's denote the number written in the *j*-th cell of the *i*-th row as *a*_{i, j}. Your task is to perform several swap operations to rearrange the numbers in the table so as to fulfill the following conditions:

- for all
*i*,*j*(1 <*i*≤*n*; 1 ≤*j*≤*c*_{i}) holds*a*_{i, j}>*a*_{i - 1, j}; - for all
*i*,*j*(1 ≤*i*≤*n*; 1 <*j*≤*c*_{i}) holds*a*_{i, j}>*a*_{i, j - 1}.

In one swap operation you are allowed to choose two different cells of the table and swap the recorded there numbers, that is the number that was recorded in the first of the selected cells before the swap, is written in the second cell after it. Similarly, the number that was recorded in the second of the selected cells, is written in the first cell after the swap.

Rearrange the numbers in the required manner. Note that you are allowed to perform any number of operations, but not more than *s*. You do not have to minimize the number of operations.

Input

The first line contains a single integer *n* (1 ≤ *n* ≤ 50) that shows the number of rows in the table. The second line contains *n* space-separated integers *c*_{i} (1 ≤ *c*_{i} ≤ 50; *c*_{i} ≤ *c*_{i - 1}) — the numbers of cells on the corresponding rows.

Next *n* lines contain table *а*. The *i*-th of them contains *c*_{i} space-separated integers: the *j*-th integer in this line represents *a*_{i, j}.

It is guaranteed that all the given numbers *a*_{i, j} are positive and do not exceed *s*. It is guaranteed that all *a*_{i, j} are distinct.

Output

In the first line print a single integer *m* (0 ≤ *m* ≤ *s*), representing the number of performed swaps.

In the next *m* lines print the description of these swap operations. In the *i*-th line print four space-separated integers *x*_{i}, *y*_{i}, *p*_{i}, *q*_{i} (1 ≤ *x*_{i}, *p*_{i} ≤ *n*; 1 ≤ *y*_{i} ≤ *c*_{xi}; 1 ≤ *q*_{i} ≤ *c*_{pi}). The printed numbers denote swapping the contents of cells *a*_{xi, yi} and *a*_{pi, qi}. Note that a swap operation can change the contents of distinct table cells. Print the swaps in the order, in which they should be executed.

Examples

Input

3

3 2 1

4 3 5

6 1

2

Output

2

1 1 2 2

2 1 3 1

Input

1

4

4 3 2 1

Output

2

1 1 1 4

1 2 1 3

Codeforces (c) Copyright 2010-2022 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/27/2022 22:24:52 (k2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|