#include <bits/stdc++.h>
using namespace std;
const int maxl = 15;
const int maxn = 16;
const int maxk = 5e5 + 5;
int n, m;
int f[1 << maxn][maxn * maxn], g[1 << maxn][maxn];
int nxt[maxk][maxn];
pair<int, int> ans = make_pair(0, -1);
vector<int> t;
map<string, int> mp;
inline void solve(int ind) {
  for (int i = (0); i < (n); ++i) nxt[t.size()][i] = t.size();
  for (int i = t.size() - 1; i >= 0; --i) {
    for (int j = (0); j < (n); ++j) nxt[i][j] = (t[i] == j ? i : nxt[i + 1][j]);
  }
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int S = (0); S < (1 << n); ++S)
    for (int i = (0); i < (n * n); ++i)
      if (f[S][i] < t.size()) {
        for (int j = (0); j < (n); ++j)
          if (!(S >> j & 1)) {
            f[S ^ (1 << j)][i + g[S][j]] =
                min(f[S ^ (1 << j)][i + g[S][j]], nxt[f[S][i]][j] + 1);
          }
      }
  for (int i = (0); i < (n * n); ++i)
    if (f[(1 << n) - 1][i] <= t.size() && n * (n - 1) / 2 - i + 1 > ans.first) {
      ans.first = n * (n - 1) / 2 - i + 1;
      ans.second = ind;
    }
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    char buf[maxl];
    scanf("%s", buf);
    string bufp = buf;
    mp[bufp] = i;
  }
  scanf("%d", &m);
  for (int S = (0); S < (1 << n); ++S)
    for (int i = (0); i < (n); ++i)
      if (!(S >> i & 1)) {
        for (int j = (0); j < (n); ++j)
          if ((S >> j & 1) && j > i) ++g[S][i];
      }
  for (int i = (0); i < (m); ++i) {
    int k;
    scanf("%d", &k);
    t.clear();
    for (int j = (0); j < (k); ++j) {
      char buf[maxl];
      scanf("%s", buf);
      string bufp = buf;
      if (mp.find(bufp) == mp.end()) continue;
      t.push_back(mp[bufp]);
    }
    solve(i);
  }
  if (!~ans.second)
    puts("Brand new problem!");
  else {
    printf("%d\n", ans.second + 1);
    printf("[:");
    for (int i = (0); i < (ans.first); ++i) putchar('|');
    puts(":]");
  }
  return 0;
}
