#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int maxn = 1 << 15 + 5;
const int maxn2 = 15 * (15 - 1) / 2 + 1;
const int inf = 1e9;
char s[16][11], t[11];
int dp[1 << 15][15 * (15 - 1) / 2 + 1];
int nxt[500016][16];
int ans1 = 0, ans2 = inf;
int vis[20];
int n;
int ones[maxn];
int fi(char m[]) {
  for (int i = 0; i < n; i++)
    if (strcmp(s[i], m) == 0) return i;
  return n;
}
int solve() {
  int num;
  scanf("%d", &num);
  fill(dp[0], dp[1 << n], inf);
  memset(nxt, -1, sizeof(nxt));
  int cnt = 0;
  for (int i = 0; i < num; i++) {
    scanf("%s", t);
    int p = fi(t);
    if (p == n) continue;
    nxt[cnt][p] = cnt;
    cnt++;
  }
  for (int i = cnt - 2; i >= 0; i--)
    for (int j = 0; j < n; j++)
      if (nxt[i][j] == -1) nxt[i][j] = nxt[i + 1][j];
  dp[0][0] = 0;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j <= n * (n - 1) / 2; j++) {
      if (dp[i][j] == inf) continue;
      for (int k = 0; k < n; k++) {
        if ((1 << k) & i) continue;
        if (nxt[dp[i][j]][k] == -1) continue;
        dp[i | (1 << k)][j + ones[i >> k]] =
            min(dp[i | (1 << k)][j + ones[i >> k]], nxt[dp[i][j]][k]);
      }
    }
  }
  for (int i = 0; i <= n * (n - 1) / 2; i++)
    if (dp[(1 << n) - 1][i] != inf) return i;
  return inf;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < 1 << n; i++) ones[i] = ones[i >> 1] + (i & 1);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  int m;
  scanf("%d", &m);
  for (int id = 1; id <= m; id++) {
    int tmp = solve();
    if (ans2 > tmp) {
      ans1 = id;
      ans2 = tmp;
    }
  }
  if (ans1 == 0)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", ans1);
    printf("[:");
    for (int i = 0; i < n * (n - 1) / 2 - ans2 + 1; i++) printf("|");
    printf(":]\n");
  }
}
