#include <bits/stdc++.h>
using namespace std;
int M[15], st[20][15];
int g[500101][26], f[32768][225], v[32768][20];
int n, m, k, best, mint, maxx;
void prepare() {
  memset(v, 0, sizeof v);
  for (int i = 0; i < (1 << n); ++i)
    for (int j = 0; j < n; ++j)
      if (!(i & (1 << j))) {
        for (int p = j + 1; p < n; ++p)
          if (i & (1 << p)) ++v[i][j];
      }
}
void wread(int *s) {
  char ch;
  for (ch = '0'; ch < 'a' || ch > 'z'; scanf("%c", &ch))
    ;
  for (s[0] = 0; ch >= 'a' && ch <= 'z'; scanf("%c", &ch) == EOF ? ch = '0' : 0)
    s[++s[0]] = ch - 'a';
}
bool cmp(int *s, int *t) {
  if (s[0] != t[0]) return false;
  for (int i = 1; i <= s[0]; ++i)
    if (s[i] != t[i]) return false;
  return true;
}
void updata(int &q, int p) {
  if (q > p) q = p;
}
int main() {
  scanf("%d", &n);
  prepare();
  maxx = (n - 1) * n / 2;
  for (int i = 1; i <= n; ++i) wread(st[i]);
  scanf("%d", &m);
  best = 0;
  mint = maxx + 1;
  for (int i0 = 1; i0 <= m; ++i0) {
    scanf("%d", &k);
    memset(g, 0, sizeof g);
    for (int i = 1; i <= k; ++i) {
      wread(M);
      for (int j = 1; j <= n; ++j)
        if (cmp(M, st[j])) g[i][j - 1] = i;
    }
    for (int i = k; i; --i)
      for (int j = 0; j < n; ++j)
        if (!g[i][j]) g[i][j] = g[i + 1][j];
    memset(f, 63, sizeof f);
    f[0][0] = 0;
    for (int i = 0, x, y; i <= (1 << n) - 1; ++i)
      for (int j = 0; j <= maxx; ++j)
        if (f[i][j] < f[0][1])
          for (int p = 0, t; p < n; ++p)
            if (((1 << p) & i) == 0) {
              x = g[f[i][j] + 1][p];
              if (x) updata(f[i | (1 << p)][j + v[i][p]], x);
            }
    int i = (1 << n) - 1, j;
    for (j = 0; j <= maxx; ++j)
      if (f[i][j] < f[0][1]) break;
    if (f[i][j] < f[0][1] && j < mint) {
      best = i0;
      mint = j;
    }
  }
  if (best) {
    printf("%d\n", best);
    printf("[:");
    for (int i = 1; i <= maxx - mint + 1; ++i) printf("|");
    printf(":]\n");
  } else
    printf("Brand new problem!\n");
  return 0;
}
