#include <bits/stdc++.h>
using namespace std;
inline int RD() {
  int x;
  scanf("%d", &x);
  return x;
}
inline int RD(int& x) { return x = RD(); }
inline int RD(int& x, int& y) {
  RD(x);
  RD(y);
}
inline int RD(int& x, int& y, int& z) {
  RD(x, y);
  RD(z);
}
const static int N = 60;
int a[N][N];
int c[N];
pair<int, int> co[N * N];
int n, s;
int main() {
  RD(n);
  for (int i = (1); i <= (n); i++) RD(c[i]), s += c[i];
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (c[i]); j++)
      RD(a[i][j]), co[a[i][j]].first = i, co[a[i][j]].second = j;
  int x, y, xl = n, yl = c[n];
  queue<pair<pair<int, int>, pair<int, int> > > q;
  for (int i = (s); i >= (1); i--) {
    x = co[i].first, y = co[i].second;
    if (xl != x || yl != y) {
      q.push(make_pair(make_pair(xl, yl), make_pair(x, y)));
      swap(co[a[xl][yl]], co[a[x][y]]);
      swap(a[xl][yl], a[x][y]);
    }
    yl--;
    if (yl == 0) {
      xl--;
      yl = c[xl];
    }
  }
  cout << q.size() << endl;
  while (!q.empty()) {
    pair<pair<int, int>, pair<int, int> > x = q.front();
    q.pop();
    cout << x.first.first << ' ' << x.first.second << ' ' << x.second.first
         << ' ' << x.second.second << endl;
  }
  return 0;
}
