#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  int l[8], totallength = 0;
  for (int i = 0; i < 8; i++) {
    if (i < N) {
      cin >> l[i];
      totallength += l[i];
    } else {
      l[i] = 0;
    }
  }
  for (int i = 0; i < 256; i++) {
    for (int j = 0; j < 256; j++) {
      for (int m = 0; m < 255; m++) {
        if (!(i & j)) {
          int first = 0, second = 0, third = 0, MP = 0;
          for (int k = 0; k < 8; k++) {
            if (i & (1 << k)) {
              if (first > 0) {
                MP += 10;
              }
              first += l[k];
            }
            if (j & (1 << k)) {
              if (second > 0) {
                MP += 10;
              }
              second += l[k];
            }
            if (m & (1 << k)) {
              if (third > 0) {
                MP += 10;
              }
              third += l[k];
            }
          }
          cout << first << " " << second << " " << third << " " << MP << endl;
        }
      }
    }
  }
}
