#include <bits/stdc++.h>
using namespace std;
int i, j, k, N, M, K, X, maxSim, indSim;
vector<string> A;
vector<string> B[30];
string W;
vector<int> p;
bool equal(const string &a, const string &b) {
  if (a.size() != b.size()) return false;
  return a == b;
}
int getInv(vector<int> &p) {
  int ret = 0;
  for (int i = 0; i < (int)p.size(); i++)
    for (int j = i + 1; j < (int)p.size(); j++)
      if (p[i] > p[j]) ret++;
  return ret;
}
int main() {
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> W;
    A.push_back(W);
  }
  cin >> M;
  for (i = 0; i < M; i++) {
    cin >> K;
    for (j = 0; j < K; j++) {
      cin >> W;
      B[i].push_back(W);
    }
  }
  p.resize(N);
  for (i = 0; i < N; i++) p[i] = i;
  maxSim = -1;
  indSim = -1;
  do {
    X = getInv(p);
    for (i = 0; i < M; i++) {
      j = 0;
      k = 0;
      while (j < N && k < (int)B[i].size()) {
        if (equal(A[p[j]], B[i][k])) {
          j++;
        }
        k++;
      }
      if (j == N) {
        int sim = N * (N - 1) / 2 - X + 1;
        if (sim > maxSim) {
          maxSim = sim;
          indSim = i;
        } else if (sim == maxSim && i < indSim) {
          maxSim = sim;
          indSim = i;
        }
      }
    }
  } while (next_permutation(p.begin(), p.end()));
  if (indSim == -1) {
    cout << "Brand new problem!";
  } else {
    cout << indSim + 1 << '\n';
    cout << "[:";
    for (i = 0; i < maxSim; i++) cout << "|";
    cout << ":]";
  }
  return 0;
}
