#include <bits/stdc++.h>
using namespace std;
const double TOLL = 1e-9;
int N, M;
vector<string> tor[20];
map<string, int> mp;
int getInv(const vector<string>& v) {
  int rv = 0;
  for (int i = 0; i < (int((v).size())); i++)
    for (int j = i + 1; j < (int((v).size())); j++) {
      int oi = mp[v[i]], oj = mp[v[j]];
      if (oi < oj) continue;
      rv++;
    }
  return rv;
}
bool subseq(const vector<string>& v, const vector<string>& t) {
  int i = 0, j = 0;
  while (i < (int((t).size())) && j < (int((v).size()))) {
    if (t[i] == v[j]) {
      j++;
    }
    i++;
  }
  return (j == (int((v).size())));
}
int main() {
  while (cin >> N) {
    vector<string> v;
    v.resize(N);
    mp.clear();
    for (int i = 0; i < N; i++) {
      cin >> v[i];
      mp[v[i]] = i;
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
      int k;
      cin >> k;
      tor[i].resize(k);
      for (int j = 0; j < k; j++) cin >> tor[i][j];
    }
    int bestInv = 100000, bestInd = -1;
    sort((v).begin(), (v).end());
    do {
      for (int i = 0; i < M; i++)
        if (subseq(v, tor[i])) {
          int inv = getInv(v);
          if (inv < bestInv) {
            bestInv = inv;
            bestInd = i + 1;
          } else if (inv == bestInv)
            bestInd = min(bestInd, i + 1);
        }
    } while (next_permutation((v).begin(), (v).end()));
    if (bestInd == -1) {
      cout << "Brand new problem!" << endl;
      continue;
    }
    int simi = (N * (N - 1)) / 2 - bestInv + 1;
    cout << bestInd << endl;
    string rv = "[:" + string(simi, '|') + ":]";
    cout << rv << endl;
  }
}
