#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<string> a(n);
  map<string, int> M;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    M[a[i]] = i;
  }
  vector<vector<int> > Inv(1 << n, vector<int>(n, 0));
  for (int mask = 1; mask < (1 << n); ++mask)
    for (int j = 0; j < n; ++j)
      if ((mask & (1 << j)) == 0)
        for (int l = 0; l < n; ++l)
          if ((mask & (1 << l)) > 0 && M[a[j]] < M[a[l]]) ++Inv[mask][j];
  int m;
  cin >> m;
  int p = -1, nr;
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    vector<string> b(k);
    for (int j = 0; j < k; ++j) cin >> b[j];
    vector<vector<int> > nast(k, vector<int>(n, INF));
    if (M.find(b[k - 1]) != M.end()) nast[k - 1][M[b[k - 1]]] = k - 1;
    for (int j = k - 2; j >= 0; --j) {
      for (int l = 0; l < n; ++l) nast[j][l] = nast[j + 1][l];
      if (M.find(b[j]) != M.end()) nast[j][M[b[j]]] = j;
    }
    vector<vector<int> > dp((1 << n), vector<int>(n * (n - 1) / 2 + 1, INF));
    for (int j = 0; j < n; ++j)
      if (nast[0][j] != INF) dp[1 << j][0] = nast[0][j];
    for (int mask = 1; mask < (1 << n); ++mask) {
      for (int inv = 0; inv <= n * (n - 1) / 2; ++inv) {
        if (dp[mask][inv] == INF) continue;
        for (int j = 0; j < n; ++j) {
          if ((mask & (1 << j)) == 0) {
            int noweInv = inv + Inv[mask][j];
            if (dp[mask][inv] + 1 < k && nast[dp[mask][inv] + 1][j] != INF)
              dp[mask | (1 << j)][noweInv] =
                  min(dp[mask | (1 << j)][noweInv], nast[dp[mask][inv] + 1][j]);
          }
        }
      }
    }
    for (int j = 0; j <= n * (n - 1) / 2; ++j) {
      if (dp[(1 << n) - 1][j] != INF && n * (n - 1) / 2 - j + 1 > p) {
        p = n * (n - 1) / 2 - j + 1;
        nr = i;
      }
    }
  }
  if (p == -1)
    cout << "Brand new problem!";
  else {
    cout << nr + 1 << endl;
    cout << "[:";
    for (int i = 0; i < p; ++i) cout << "|";
    cout << ":]";
  }
  return 0;
}
