#include <bits/stdc++.h>
using namespace std;
int n, m, pmax, imin;
string s[20];
int vs[15][500005];
int nxt[500005][15];
int dp[66000][110];
int inv[66000][20];
char stmp[15];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (1 << n); i++)
    for (int j = 0; j < n; j++)
      if (~i & (1 << j))
        for (int k = j + 1; k < n; k++)
          if (i & (1 << k)) inv[i][j]++;
  for (int i = 1; i <= n; i++) {
    scanf("%s", stmp);
    s[i] = stmp;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int sz;
    scanf("%d", &sz);
    for (int j = 1; j <= sz; j++) {
      scanf("%s", stmp);
      int len = strlen(stmp);
      for (int k = 1; k <= n; k++)
        if (len == int(s[k].size())) {
          bool ok = true;
          for (int ii = 0; ii < len; ii++) ok &= stmp[ii] == s[k][ii];
          if (ok) vs[i][j] = k;
        }
    }
    for (int j = 0; j <= sz + 1; j++)
      for (int k = 1; k <= n; k++) nxt[j][k] = sz + 1;
    for (int j = sz; j >= 0; j--) {
      for (int k = 1; k <= n; k++) nxt[j][k] = nxt[j + 1][k];
      if (vs[i][j]) nxt[j][vs[i][j]] = j;
    }
    for (int j = 0; j < (1 << n); j++)
      for (int k = 0; k < 110; k++) dp[j][k] = sz + 1;
    dp[0][0] = 0;
    for (int j = 0; j < (1 << n); j++)
      for (int k = 0; k < n; k++)
        if (~j & (1 << k))
          for (int l = 0; l <= n * (n - 1) / 2; l++)
            if (dp[j][l] != sz + 1)
              dp[j ^ (1 << k)][l + inv[j][k]] = min(
                  dp[j ^ (1 << k)][l + inv[j][k]], nxt[dp[j][l] + 1][k + 1]);
    for (int j = 0; j <= n * (n - 1) / 2; j++)
      if (dp[(1 << n) - 1][j] != sz + 1) {
        if (pmax < n * (n - 1) / 2 - j + 1) {
          pmax = n * (n - 1) / 2 - j + 1;
          imin = i;
        }
        break;
      }
  }
  if (!pmax)
    puts("Brand new problem!");
  else {
    printf("%d\n", imin);
    printf("[:");
    for (int i = 1; i <= pmax; i++) putchar('|');
    puts(":]");
  }
  return 0;
}
