#include <bits/stdc++.h>
using namespace std;
const int MAXN = 18;
const int MAXK = 550000;
const int MAXS = 33000;
const int MAXT = 150;
string s[MAXN];
int d[MAXK], p[MAXK][MAXN], b[MAXN];
int f[MAXS][MAXT];
int main() {
  int n, m, T;
  scanf("%d", &n);
  T = n * (n - 1) / 2;
  for (int i = 1; i <= n; i++) cin >> s[i];
  scanf("%d", &m);
  int mx = -1, id;
  for (int l = 1; l <= m; l++) {
    int k, c = 0;
    scanf("%d", &k);
    for (int i = 1; i <= k; i++) {
      string t;
      cin >> t;
      for (int j = 1; j <= n; j++)
        if (t == s[j]) {
          d[++c] = j;
          break;
        }
    }
    for (int i = 1; i <= n; i++) p[c + 1][i] = b[i] = c + 1;
    for (int i = c; i >= 0; i--) {
      for (int j = 1; j <= n; j++) p[i][j] = b[j];
      b[d[i]] = i;
    }
    for (int S = 0; S < 1 << n; S++)
      for (int r = 0; r <= T; r++) f[S][r] = c + 1;
    f[0][0] = 0;
    for (int S = 1; S < 1 << n; S++)
      for (int r = 0; r <= T; r++) {
        int cnt = __builtin_popcount(S);
        for (int i = 1; i <= n; i++)
          if (S & 1 << i - 1) {
            cnt--;
            if (r >= cnt)
              f[S][r] = min(f[S][r], p[f[S ^ 1 << i - 1][r - cnt]][i]);
          }
      }
    for (int i = 0; i <= T; i++)
      if (f[(1 << n) - 1][i] != c + 1) {
        if (T - i + 1 > mx) mx = T - i + 1, id = l;
        break;
      }
  }
  if (mx == -1)
    puts("Brand new problem!");
  else {
    printf("%d\n[:", id);
    for (int i = 1; i <= mx; i++) putchar('|');
    puts(":]");
  }
  return 0;
}
