#include <bits/stdc++.h>
using namespace std;
char st[18][18];
int cmp[18][18];
int nx[40000][18];
char ns[500008][18];
int nxt[500008][18];
int dp[40000][250];
int a[500008];
int mi[20];
int n, i, j, k, h, hh, kk, m, l, ii, ans;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) cin >> st[i];
  for (k = 1; k <= n; k++)
    for (j = 1; j < k; j++) cmp[k][j]++;
  for (i = 0; i <= (1 << n) - 1; i++)
    for (j = 1; j <= n; j++)
      if (!((1 << (j - 1)) & i))
        for (k = 1; k <= n; k++)
          if ((1 << (k - 1)) & i) nx[i][j] += cmp[k][j];
  scanf("%d", &m);
  ans = 2e9;
  for (int cm = 1; cm <= m; cm++) {
    scanf("%d", &l);
    for (j = 1; j <= l; j++) cin >> ns[j];
    k = 0;
    for (j = 1; j <= l; j++) {
      for (h = 1; h <= n; h++)
        if (strlen(ns[j]) == strlen(st[h])) {
          for (hh = 0; hh < strlen(st[h]); hh++)
            if (ns[j][hh] != st[h][hh]) break;
          if (hh == strlen(st[h])) {
            a[++k] = h;
            break;
          }
        }
    }
    memset(mi, 122, sizeof(mi));
    for (i = k; i >= 0; i--) {
      for (j = 1; j <= n; j++) nxt[i][j] = mi[j];
      mi[a[i]] = i;
    }
    kk = k;
    memset(dp, 122, sizeof(dp));
    dp[0][0] = 0;
    for (i = 0; i < (1 << n) - 1; i++)
      for (k = 0; k <= n * n; k++)
        for (j = 1; j <= n; j++)
          if ((dp[i][k] < 1e9) && (!(i & (1 << (j - 1)))) &&
              (nxt[dp[i][k]][j] < 1e9))
            dp[i + (1 << (j - 1))][k + nx[i][j]] =
                min(dp[i + (1 << (j - 1))][k + nx[i][j]], nxt[dp[i][k]][j]);
    for (i = 0; i <= n * n; i++)
      if (dp[(1 << n) - 1][i] <= kk) break;
    if ((i < ans) && (i <= n * n)) ii = cm, ans = i;
  }
  if (ans < 1e9) {
    printf("%d\n", ii);
    printf("[:");
    for (i = 1; i <= n * (n - 1) / 2 - ans + 1; i++) printf("|");
    puts(":]");
  } else
    puts("Brand new problem!");
  return 0;
}
