#include <bits/stdc++.h>
using namespace std;
int n, a[55], s[55][55], h, ans, p[100005];
struct pis {
  int x, y, z;
} f[100005];
int pp[10005][10];
inline int cmp(pis k, pis l) { return k.z > l.z; }
int main() {
  scanf("%d", &n);
  int i, j;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= a[i]; j++) {
      scanf("%d", &s[i][j]);
      f[++h].x = i, f[h].y = j;
      f[h].z = s[i][j];
    }
  sort(f + 1, f + h + 1, cmp);
  for (i = 1; i <= h; i++) p[f[i].z] = i;
  int num = 0;
  for (i = n; i >= 1; i--)
    for (j = a[i]; j >= 1; j--)
      if (f[++num].z == s[i][j])
        continue;
      else {
        s[f[num].x][f[num].y] = s[i][j];
        f[p[s[i][j]]].x = f[num].x;
        f[p[s[i][j]]].y = f[num].y;
        pp[++ans][1] = f[num].x;
        pp[ans][2] = f[num].y;
        pp[ans][3] = i;
        pp[ans][4] = j;
      }
  printf("%d\n", ans);
  for (i = 1; i <= ans; i++)
    printf("%d %d %d %d\n", pp[i][1], pp[i][2], pp[i][3], pp[i][4]);
  return 0;
}
