#include <bits/stdc++.h>
typedef struct {
  int x, y;
} CAMB;
int main() {
  int n, c = 0, i, j, can = 1, Ncorrec, Nmatr;
  scanf("%d", &n);
  int *Numat[n], *aux[n];
  int Canmat[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &Canmat[i]);
    c += Canmat[i];
    Numat[i] = (int *)malloc(sizeof(int) * Canmat[i]);
    aux[i] = (int *)malloc(sizeof(int) * Canmat[i]);
  }
  CAMB numero[c];
  CAMB camb[c * 2];
  c = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < Canmat[i]; j++) {
      scanf("%d", &(Numat[i][j]));
      numero[Numat[i][j] - 1].x = i;
      numero[Numat[i][j] - 1].y = j;
      c++;
      aux[i][j] = c;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < Canmat[i]; j++) {
      Nmatr = Numat[i][j];
      Ncorrec = aux[i][j];
      if (Ncorrec != Nmatr) {
        Numat[i][j] = Ncorrec;
        Numat[numero[Ncorrec - 1].x][numero[Ncorrec - 1].y] = Nmatr;
        numero[Nmatr - 1].x = numero[Ncorrec - 1].x;
        numero[Nmatr - 1].y = numero[Ncorrec - 1].y;
        numero[Ncorrec - 1].x = i;
        numero[Ncorrec - 1].y = j;
        camb[can - 1].x = i;
        camb[can - 1].y = j;
        camb[can].x = numero[Nmatr - 1].x;
        camb[can].y = numero[Nmatr - 1].y;
        can = can + 2;
      }
    }
  }
  if (can != 1) {
    can = can - 2;
    printf("%d\n", (can / 2 + 1));
    for (i = 0; i <= can; i = i + 2) {
      printf("%d %d %d %d \n", camb[i].x + 1, camb[i].y + 1, camb[i + 1].x + 1,
             camb[i + 1].y + 1);
    }
  } else {
    printf("0");
  }
  return 0;
}
