#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.in");
ofstream fout("out.out");
const int N = 15 + 2, M = 1 << 16, K = 5e5 + 2, inf = 1e9;
const long long p = 29;
int n, m, k, ind[N][K], dp[M][120], lg[M], pw[N], res = inf, idx;
string a[N], b[K];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i <= n; i++) {
    pw[i] = 1 << i;
    lg[pw[i]] = i;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) cin >> b[j];
    memset(ind, 0, sizeof ind);
    memset(dp, 0, sizeof dp);
    for (int j = 0; j < n; j++) {
      ind[j][k] = inf;
      for (int h = k - 1; h >= 0; h--)
        if (b[h] == a[j])
          ind[j][h] = h;
        else
          ind[j][h] = ind[j][h + 1];
    }
    for (int mask = 1; mask < pw[n]; mask++) {
      int msk = mask;
      vector<int> d;
      while (msk) {
        int bit = msk & (-msk);
        msk &= ~bit;
        d.push_back(lg[bit]);
      }
      for (int inv = 0; inv <= (d.size()) * (d.size() - 1) / 2; inv++) {
        int &cur = dp[mask][inv];
        cur = inf;
        for (int j = d.size() - 1; j >= 0; j--) {
          int cnt = d.size() - j - 1;
          if (inv - cnt < 0) break;
          if (inv - cnt > (d.size() - 1) * (d.size() - 1 - 1) / 2) continue;
          int prev = dp[mask & ~pw[d[j]]][inv - cnt];
          if (prev == inf) continue;
          cur = min(cur, ind[d[j]][prev] + 1);
        }
        if (mask == pw[n] - 1) {
          if (cur < inf && inv < res) res = inv, idx = i + 1;
        }
      }
    }
  }
  if (res == inf)
    cout << "Brand new problem!" << endl;
  else
    cout << idx << endl
         << "[:" << string((n) * (n - 1) / 2 - res + 1, '|') << ":]" << endl;
  return 0;
}
