#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, v;
  long long w;
};
long long MOD = 1000000007;
long long _MOD = 1000000009;
int INF = INT_MAX / 10;
double EPS = 1e-10;
int main() {
  int N;
  cin >> N;
  int L = N * (N - 1) / 2;
  vector<vector<int> > unko(1 << N, vector<int>(N));
  for (int S = 0; S < 1 << N; S++)
    for (int i = 0; i < N; i++)
      if (!(S >> i & 1))
        for (int _i = i + 1; _i < N; _i++) unko[S][i] += S >> _i & 1;
  vector<string> word(N);
  for (int i = 0; i < N; i++) cin >> word[i];
  int T;
  cin >> T;
  int mi = INF, t0;
  for (int t = 0; t < T; t++) {
    int M;
    cin >> M;
    vector<vector<bool> > a(M, vector<bool>(N));
    for (int j = 0; j < M; j++) {
      string s;
      cin >> s;
      for (int i = 0; i < N; i++) a[j][i] = (word[i] == s);
    }
    vector<vector<int> > nxt(M + 2, vector<int>(N, M + 1));
    for (int j = M - 1; j >= 0; j--)
      for (int i = 0; i < N; i++) {
        nxt[j][i] = nxt[j + 1][i];
        if (a[j][i]) nxt[j][i] = j + 1;
      }
    vector<vector<int> > dp(1 << N, vector<int>(L + 1, M + 1));
    dp[0][0] = 0;
    for (int S = 0; S < 1 << N; S++)
      for (int x = 0; x < L + 1; x++) {
        if (dp[S][x] == M + 1) continue;
        for (int i = 0; i < N; i++)
          if (!(S >> i & 1)) {
            int _S = S | 1 << i, _x = x + unko[S][i];
            dp[_S][_x] = min(dp[_S][_x], nxt[dp[S][x]][i]);
          }
      }
    int ans = INF;
    for (int x = 0; x < L + 1; x++)
      if (dp.back()[x] != M + 1) ans = min(ans, x);
    if (ans < mi) mi = ans, t0 = t;
  }
  if (mi == INF) {
    cout << "Brand new problem!" << endl;
    return 0;
  }
  cout << t0 + 1 << endl;
  cout << "[:";
  for (int t = 0; t < L - mi + 1; t++) cout << '|';
  cout << ":]" << endl;
}
