#include <bits/stdc++.h>
using namespace std;
const int N = (int)5e5 + 5;
int n, m, k, dp[1 << 15][110], nxt[N][16];
vector<int> a;
map<string, int> mp;
void update(int &x, int y) {
  if (x == -1 || x > y) x = y;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    mp[s] = i;
  }
  cin >> m;
  int idx = 0, cnt = 0, lmt = n * (n - 1) / 2;
  for (int i = 1; i <= m; ++i) {
    cin >> k;
    string s;
    a.clear();
    for (int j = 1; j <= k; ++j) {
      cin >> s;
      if (mp.find(s) != mp.end())
        a.push_back(mp[s]);
      else
        a.push_back(0);
    }
    for (int j = 1; j <= n; ++j) nxt[k + 1][j] = k + 1;
    for (int j = k; j >= 1; --j) {
      for (int x = 1; x <= n; ++x) {
        if (a[j - 1] == x)
          nxt[j][x] = j;
        else
          nxt[j][x] = nxt[j + 1][x];
      }
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for (int x = 0; x < (1 << n) - 1; ++x) {
      for (int y = 0; y <= lmt; ++y)
        if (dp[x][y] != -1) {
          int tmp = 0;
          for (int z = n - 1; z >= 0; --z) {
            if ((x >> z) & 1)
              ++tmp;
            else {
              int pos = nxt[dp[x][y] + 1][z + 1];
              if (pos <= k && y + tmp <= lmt)
                update(dp[x | (1 << z)][y + tmp], pos);
            }
          }
        }
    }
    for (int y = 0; y <= lmt; ++y)
      if (dp[(1 << n) - 1][y] != -1) {
        if (lmt - y + 1 > cnt) idx = i, cnt = lmt - y + 1;
        break;
      }
  }
  if (!idx) return puts("Brand new problem!"), 0;
  printf("%d\n[:", idx);
  for (int i = 1; i <= cnt; ++i) printf("|");
  printf(":]");
  return 0;
}
