#include <bits/stdc++.h>
using namespace std;
const int N = 42, M = 22;
int n, m, C, arenda[M], match[M];
vector<int> p, time_A, time_B, ycl, q1, q2;
vector<vector<int>> time_play, b;
vector<pair<pair<int, int>, pair<int, int>>> ans;
int get_max_time() {
  int MAX = 0;
  for (int i = 1; i <= n; i++) MAX = max(MAX, time_A[i]);
  for (int i = 1; i <= m; i++) MAX = max(MAX, time_B[i]);
  return MAX;
}
inline bool cmpA(int x, int y) { return time_A[x] > time_A[y]; };
inline bool cmpB(int x, int y) { return time_B[x] > time_B[y]; };
bool dfs(int p) {
  for (int i = 1; i <= m; i++)
    if (time_play[p][q2[i]] && !arenda[q2[i]]) {
      arenda[q2[i]] = 1;
      if (!match[q2[i]] || dfs(match[q2[i]])) {
        match[q2[i]] = p;
        return true;
      };
    };
  return false;
};
int main() {
  p.resize(M);
  time_play.resize(N);
  b.resize(N);
  time_A.resize(N);
  time_B.resize(M);
  ycl.resize(M);
  q1.resize(N);
  q2.resize(M);
  for (int i = 0; i < N; i++) {
    time_play[i].resize(M);
    b[i].resize(M);
  };
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n >> m >> C;
  for (int i = 1; i <= m; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    while (k--) {
      int x, t;
      cin >> x >> t;
      time_play[i][x] = t;
      time_A[i] += t;
      time_B[x] += t;
    };
  };
  for (int i = 1; i <= m; i++) ycl[i] = i;
  int jz = m;
  bool flag = true;
  while (flag) {
    int mx = get_max_time();
    flag = false;
    for (int i = 1; i <= jz; i++) {
      if (time_B[i] == mx && !arenda[i]) {
        if (C < p[i]) break;
        C -= p[i];
        flag = true;
        time_B[i] = time_B[++m] = 0;
        ycl[m] = i;
        arenda[i] = 1;
        for (int o = 1; o <= n; o++) {
          if (time_B[i] <= time_B[m])
            time_play[o][m] = time_play[o][i] / 2;
          else
            time_play[o][m] = (time_play[o][i] + 1) / 2;
          time_play[o][i] -= time_play[o][m];
          time_B[m] += time_play[o][m];
          time_B[i] += time_play[o][i];
        };
      };
    };
  };
  int T = get_max_time();
  cout << T << endl;
  for (int i = 1; i <= jz; i++) cout << arenda[i];
  cout << endl;
  for (int i = 1; i <= n; i++) q1[i] = i;
  for (int i = 1; i <= m; i++) q2[i] = i;
  int TT = 0;
  while (TT < T) {
    sort(&q1[1], &q1[n + 1], cmpA);
    sort(&q2[1], &q2[m + 1], cmpB);
    memset(match, 0, sizeof(match));
    int tmp = 1000000000, mx = 0;
    for (int i = 1; i <= n; i++) {
      memset(arenda, 0, sizeof(arenda));
      if (!dfs(q1[i])) mx = max(mx, time_A[q1[i]]);
    };
    for (int i = 1; i <= m; i++)
      if (match[i])
        tmp = min(tmp, time_play[match[i]][i]);
      else
        mx = max(mx, time_B[i]);
    tmp = min(tmp, max(time_A[q1[1]], time_B[q2[1]]) - mx);
    for (int i = 1; i <= m; i++)
      if (match[i]) {
        time_play[match[i]][i] -= tmp;
        time_B[i] -= tmp;
        time_A[match[i]] -= tmp;
        ans.push_back(
            make_pair(make_pair(match[i], ycl[i]), make_pair(TT, tmp)));
      };
    TT += tmp;
  };
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i.first.first << " ";
    cout << i.first.second << " ";
    cout << i.second.first << " ";
    cout << i.second.second << endl;
  };
};
