#include <bits/stdc++.h>
using namespace std;
inline long long pow(long long a, long long b, long long mo) {
  if (!a) return 0;
  long long tmp = 1;
  for (; b; b >>= 1) {
    if (b & 1) tmp = (long long)tmp * a % mo;
    a = (long long)a * a % mo;
  }
  return tmp;
}
template <class T>
inline void R(T &xx) {
  xx = 0;
  char ch = getchar();
  bool F = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') F = 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
  if (F) xx = -xx;
}
string a[20], b[500111];
int n, m, _, nxt[20][500111], f[33333][250], ans = (1 << 30), an;
int main() {
  R(n);
  for (int i = (1); i <= (n); i++) cin >> a[i];
  R(_);
  for (int __ = 0; __ < (int)(_); __++) {
    R(m);
    for (int i = (1); i <= (m); i++) cin >> b[i];
    for (int i = (1); i <= (n); i++) nxt[i][m + 1] = m + 1;
    for (int i = (1); i <= (n); i++)
      for (int j = (m); j >= (1); j--)
        nxt[i][j] = (a[i] == b[j]) ? j : nxt[i][j + 1];
    memset(f, 0x7f, sizeof(f));
    f[0][0] = 0;
    for (int i = 0; i < (int)((1 << n)); i++)
      for (int j = (0); j <= (n * n); j++)
        if (f[i][j] <= m)
          for (int k = 0; k < (int)(n); k++)
            if (!(i >> k & 1)) {
              int x = j;
              for (int l = (k); l < (int)(n); l++)
                if (i >> l & 1) x++;
              f[i | 1 << k][x] = min(f[i | 1 << k][x], nxt[k + 1][f[i][j] + 1]);
            }
    for (int i = (0); i <= (n * n); i++)
      if (f[(1 << n) - 1][i] <= m) {
        if (i < ans) ans = i, an = __ + 1;
        break;
      }
  }
  if (ans >= n * n)
    puts("Brand new problem!");
  else {
    printf("%d\n", an);
    printf("[:");
    for (int i = 0; i < (int)((n - 1) * n / 2 - ans + 1); i++) printf("|");
    puts(":]");
  }
  return 0;
}
