#include <bits/stdc++.h>
using namespace std;
int dp[1 << 15][106], nxt[500001][15];
string s[15], p[500001];
inline void upd(int &a, int b) {
  if (a == -1 || b < a) a = b;
}
int main() {
  int n;
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> s[i];
  int m;
  cin >> m;
  int ans = 0, ansidx;
  for (int P = 1; P <= m; ++P) {
    memset(dp, -1, sizeof(dp));
    int k;
    cin >> k;
    for (int i = 1; i <= k; ++i) cin >> p[i];
    int idx[15];
    memset(idx, -1, sizeof(idx));
    for (int i = k; i >= 1; --i) {
      int str = 0;
      for (; str < n && s[str] != p[i]; ++str)
        ;
      if (str < n) idx[str] = i;
      for (int j = 0; j < n; ++j) nxt[i][j] = idx[j];
    }
    dp[0][0] = 0;
    int mxinv = n * (n - 1) / 2;
    for (int i = 0; i < (1 << n); ++i)
      for (int j = 0; j <= mxinv; ++j)
        if (dp[i][j] != -1 && dp[i][j] < k) {
          int delta = 0;
          for (int l = n - 1; l >= 0; --l) {
            if ((i >> l) & 1)
              ++delta;
            else if (nxt[dp[i][j] + 1][l] != -1)
              upd(dp[i ^ (1 << l)][j + delta], nxt[dp[i][j] + 1][l]);
          }
        }
    for (int j = 0; j <= mxinv; ++j)
      if (dp[(1 << n) - 1][j] != -1) {
        if (mxinv - j + 1 > ans) {
          ans = mxinv - j + 1;
          ansidx = P;
        }
        break;
      }
  }
  if (!ans)
    cout << "Brand new problem!" << endl;
  else {
    cout << ansidx << endl << "[:";
    for (int i = 1; i <= ans; ++i) cout << "|";
    cout << ":]" << endl;
  }
  return 0;
}
