#include <bits/stdc++.h>
using namespace std;
void swap(int &x, int &y) {
  int t = x;
  x = y;
  y = t;
}
int main() {
  int n, i, j, m, curs, s = 0, a[100][100], x[5000], y[5000];
  int c[100], b1x[5000], b2x[5000], b1y[5000], b2y[5000];
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    s += c[i];
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= c[i]; j++) {
      scanf("%d", &a[i][j]);
      x[a[i][j]] = i;
      y[a[i][j]] = j;
    }
  j = 1;
  m = 0;
  curs = c[1];
  for (i = 1; i <= s; i++) {
    if (i > curs) curs += c[++j];
    if (i != a[j][i - curs + c[j]]) {
      x[a[j][i - curs + c[j]]] = x[i];
      y[a[j][i - curs + c[j]]] = y[i];
      swap(a[x[i]][y[i]], a[j][i - curs + c[j]]);
      m++;
      b1x[m] = x[i];
      b1y[m] = y[i];
      b2x[m] = j;
      b2y[m] = i - curs + c[j];
    }
  }
  printf("%d\n", m);
  for (i = 1; i <= m; i++)
    printf("%d %d %d %d\n", b1x[i], b1y[i], b2x[i], b2y[i]);
  return 0;
}
