#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k[m];
  std::vector<int> s[m];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  std::vector<int> p;
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  n = 4;
  for (int i = 0; i < n; i++) {
    std::vector<int> data(n, 0);
    for (int j = n - 1; j >= (n - i); j--) data[j] = 1;
    do {
      for (int j = 0; j < m; j++) {
      }
      for (int j = 0; j < n; j++) cout << data[j] << ",";
      cout << endl;
    } while (next_permutation(data.begin(), data.end()));
    cout << "-----" << endl;
  }
  return 0;
}
