#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, inf = 0x3f3f3f3f;
int n, m, mn = inf, id;
int num[1 << 15], len[20], a[20][N], nxt[N][20], dp[1 << 15][16 * 16];
char s[20][15], t[20];
int calc(char t[]) {
  for (int i = 1; i <= n; i++)
    if (strcmp(s[i], t) == 0) return i;
  return n + 1;
}
int main() {
  cin >> n;
  for (int S = 0; S <= (1 << n) - 1; S++) num[S] = (num[S >> 1] + (S & 1));
  for (int i = 1; i <= n; i++) scanf("%s", s[i]);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &len[i]);
    for (int j = 1; j <= len[i]; j++) {
      scanf("%s", t);
      a[i][j] = calc(t);
    }
    memset(nxt, -1, sizeof(nxt));
    for (int j = len[i]; j >= 0; --j) {
      for (int k = 1; k <= n + 1; k++) nxt[j][k] = nxt[j + 1][k];
      nxt[j][a[i][j]] = j;
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for (int S = 0; S <= (1 << n) - 1; S++) {
      for (int j = 0; j <= n * (n - 1) / 2; j++) {
        if (dp[S][j] == inf) continue;
        for (int k = 1; k <= n; k++) {
          if (S & (1 << (k - 1))) continue;
          if (nxt[dp[S][j]][k] == -1) continue;
          dp[S | (1 << (k - 1))][j + num[S >> k]] =
              min(dp[S | (1 << (k - 1))][j + num[S >> k]], nxt[dp[S][j]][k]);
        }
      }
    }
    for (int j = 0; j <= n * (n - 1) / 2; j++) {
      if (dp[(1 << n) - 1][j] != inf) {
        if (mn > j) {
          mn = j, id = i;
        }
        break;
      }
    }
  }
  if (!id)
    puts("Brand new problem!");
  else {
    printf("%d\n", id);
    printf("[:");
    for (int i = 1; i <= n * (n - 1) / 2 - mn + 1; i++) printf("|");
    puts(":]");
  }
  return 0;
}
