#include <bits/stdc++.h>
const int maxn = 300;
int a[maxn], b[maxn][maxn], c[maxn], flag[maxn][maxn];
struct node {
  int x, y, z;
} d[maxn * 6], e[maxn * 6];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    memset(a, 0, sizeof(a));
    memset(c, 0, sizeof(c));
    memset(flag, 0, sizeof(flag));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= a[i]; j++) scanf("%d", &b[i][j]);
    }
    int len = 0, len1 = 0, len2 = 0;
    for (int i = 1; i <= a[1]; i++) {
      int x = 1;
      int y = i;
      int fla = 0;
      while (y <= a[x] && y > 0) {
        fla = 1;
        flag[x][y] = 1;
        d[++len].x = x;
        d[len].y = y;
        d[len].z = b[x][y];
        c[len1]++;
        x++;
        y--;
      }
      if (fla) len1++;
    }
    for (int i = 2; i <= n; i++) {
      int x = i;
      int y = a[i];
      int fla = 0;
      while (y <= a[x] && (!flag[x][y]) && y > 0) {
        fla = 1;
        flag[x][y] = 1;
        d[++len].x = x;
        d[len].y = y;
        d[len].z = b[x][y];
        c[len1]++;
        x++;
        y--;
      }
      if (fla) len1++;
    }
    int sum = 0;
    for (int i = 0; i < len1; i++) {
      int x = sum + 1, y = sum + c[i];
      sum += c[i];
      for (int j = x; j <= y; j++) {
        if (d[j].z >= x && d[j].z <= y)
          continue;
        else {
          for (int k = y + 1; k <= len; k++) {
            if (d[k].z >= x && d[k].z <= y) {
              e[len2++] = d[j];
              e[len2++] = d[k];
              int temp = d[k].z;
              d[k].z = d[j].z;
              d[j].z = temp;
              break;
            }
          }
        }
      }
    }
    printf("%d\n", len2 / 2);
    for (int i = 0; i < len2; i += 2)
      printf("%d %d %d %d\n", e[i].x, e[i].y, e[i + 1].x, e[i + 1].y);
  }
  return 0;
}
