#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXCHILD = 40;
const int MAXMACHINE = 10;
const int MAXN = MAXCHILD + 2 * MAXMACHINE;
typedef struct Ass {
  int ch, ma, t, len;
  Ass() {}
  Ass(int ch, int ma, int t, int len) : ch(ch), ma(ma), t(t), len(len) {}
} Ass;
int nchild, omachine, nmachine, budget;
int cost[MAXMACHINE];
int A[MAXCHILD][2 * MAXMACHINE];
int childsum[MAXCHILD], machinesum[2 * MAXMACHINE];
bool machinerented[MAXMACHINE];
int mp[2 * MAXMACHINE];
int n;
int B[MAXN][MAXN];
void makeb(int sum) {
  n = nchild + nmachine;
  memset(B, 0, sizeof(B));
  for (int i = (0); i < (nchild); ++i)
    for (int j = (0); j < (nmachine); ++j) B[i][j] = A[i][j];
  for (int i = (0); i < (nchild); ++i) B[i][nmachine + i] = sum - childsum[i];
  for (int i = (0); i < (nmachine); ++i) B[nchild + i][i] = sum - machinesum[i];
  int ch = 0, ma = 0, chrem = childsum[ch], marem = machinesum[ma];
  while (ch < nchild || ma < nmachine) {
    int cur = min(chrem, marem);
    if (cur != 0) B[nchild + ma][nmachine + ch] = cur;
    chrem -= cur;
    marem -= cur;
    if (ch < nchild && chrem == 0)
      ++ch, chrem = ch >= nchild ? 0 : childsum[ch];
    if (ma < nmachine && marem == 0)
      ++ma, marem = ma >= nmachine ? 0 : machinesum[ma];
  }
  assert(ch == nchild && ma == nmachine);
}
vector<Ass> ass;
bool done[MAXN];
int match[MAXN];
bool augment(int at) {
  if (done[at])
    return false;
  else
    done[at] = true;
  for (int to = (0); to < (n); ++to)
    if (B[at][to] > 0 && (match[to] == -1 || augment(match[to]))) {
      match[to] = at;
      return true;
    }
  return false;
}
void makeassignments() {
  int t = 0;
  ass.clear();
  while (true) {
    int left = 0;
    for (int i = (0); i < (n); ++i)
      for (int j = (0); j < (n); ++j) left += B[i][j];
    if (left == 0) break;
    for (int j = (0); j < (n); ++j) done[j] = false, match[j] = -1;
    for (int i = (0); i < (n); ++i) {
      assert(augment(i));
      for (int j = (0); j < (n); ++j) done[j] = false;
    }
    int len = INT_MAX;
    for (int i = (0); i < (n); ++i) len = min(len, B[match[i]][i]);
    for (int i = (0); i < (n); ++i) B[match[i]][i] -= len;
    for (int i = (0); i < (n); ++i)
      if (i < nmachine && match[i] < nchild)
        ass.push_back(Ass(match[i], mp[i], t, len));
    t += len;
  }
}
void run() {
  scanf("%d%d%d", &nchild, &nmachine, &budget);
  for (int i = (0); i < (nmachine); ++i) scanf("%d", &cost[i]);
  memset(A, 0, sizeof(A));
  for (int i = (0); i < (nchild); ++i) {
    int cnt;
    scanf("%d", &cnt);
    for (int j = (0); j < (cnt); ++j) {
      int kind, len;
      scanf("%d%d", &kind, &len);
      --kind;
      A[i][kind] += len;
    }
  }
  for (int i = (0); i < (nchild); ++i) childsum[i] = 0;
  for (int i = (0); i < (nmachine); ++i)
    machinesum[i] = 0, machinerented[i] = false, mp[i] = i;
  int left = budget;
  omachine = nmachine;
  for (int i = (0); i < (nchild); ++i)
    for (int j = (0); j < (nmachine); ++j)
      childsum[i] += A[i][j], machinesum[j] += A[i][j];
  while (true) {
    int idx = -1;
    for (int i = (0); i < (nmachine); ++i)
      if (!machinerented[mp[i]] && cost[mp[i]] <= left &&
          (idx == -1 || machinesum[i] > machinesum[idx]))
        idx = i;
    if (idx == -1) break;
    machinerented[idx] = true;
    left -= cost[mp[idx]];
    int nidx = nmachine++;
    machinesum[nidx] = 0;
    mp[nidx] = mp[idx];
    int rem = machinesum[idx] / 2;
    for (int i = (0); i < (nchild); ++i) {
      int cur = min(rem, A[i][idx]);
      A[i][idx] -= cur;
      A[i][nidx] += cur;
      machinesum[idx] -= cur;
      machinesum[nidx] += cur;
      rem -= cur;
    }
  }
  int ret = 0;
  for (int i = (0); i < (nchild); ++i) ret = max(ret, childsum[i]);
  for (int i = (0); i < (nmachine); ++i) ret = max(ret, machinesum[i]);
  printf("%d\n", ret);
  for (int i = (0); i < (omachine); ++i) printf("%d", machinerented[i] ? 1 : 0);
  puts("");
  makeb(ret);
  makeassignments();
  printf("%d\n", ((int)(ass).size()));
  for (int i = (0); i < (((int)(ass).size())); ++i)
    printf("%d %d %d %d\n", ass[i].ch + 1, ass[i].ma + 1, ass[i].t, ass[i].len);
}
int main() {
  run();
  return 0;
}
