#include <bits/stdc++.h>
long double eps = 1e-12;
using namespace std;
const char al[100] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                      'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                      'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  int sum = 0;
  int x;
  vector<vector<int> > matrix(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    sum += c[i];
    matrix[i].resize(c[i]);
  }
  vector<pair<int, int> > go(sum + 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < c[i]; j++) {
      int x;
      cin >> x;
      go[x] = make_pair(i, j);
      matrix[i][j] = x;
    }
  }
  vector<pair<pair<int, int>, pair<int, int> > > ans;
  int count = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < c[i]; j++) {
      if (matrix[i][j] != count) {
        ans.push_back(make_pair(make_pair(i, j), go[count]));
        matrix[go[count].first][go[count].second] = matrix[i][j];
        swap(go[count], go[matrix[i][j]]);
      }
      count++;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first.first + 1 << " " << ans[i].first.second + 1 << " "
         << ans[i].second.first + 1 << " " << ans[i].second.second + 1 << endl;
  }
}
