#include <bits/stdc++.h>
using namespace std;
map<string, int> G;
const int inf = 123456789;
int n, e[40], m, q[40], H[1 << 20];
int f[1 << 16], ans = inf, A;
char s[100];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    e[i] = 1 << (i - 1);
    q[i] = (1 << i) - 1;
    scanf("%s", s);
    G[s] = i;
  }
  H[0] = 0;
  for (int i = 1; i <= q[n]; ++i) H[i] = H[i - (i & -i)] + 1;
  scanf("%d", &m);
  for (int i = 1, now, k; i <= m; ++i) {
    scanf("%d", &k);
    for (int j = 0; j <= q[n]; ++j) f[j] = inf;
    f[0] = now = 0;
    for (int j = 1, p; j <= k; ++j) {
      scanf("%s", s);
      p = G.count(s);
      if (!p || (now & e[p = G[s]])) continue;
      now = (now & q[p - 1]) | e[p];
      for (int l = 0; l <= q[n]; ++l)
        if ((l & e[p]) == 0 && f[l] < inf)
          if (f[l | e[p]] > f[l] + H[l & (q[n] - q[p])])
            f[l | e[p]] = f[l] + H[l & (q[n] - q[p])];
    }
    if (f[q[n]] < ans) ans = f[q[n]], A = i;
  }
  if (ans == inf)
    puts("Brand new problem!");
  else {
    ans = n * (n - 1) / 2 - ans + 1;
    printf("%d\n[:", A);
    for (int i = 1; i <= ans; ++i) printf("|");
    printf(":]\n");
  }
  return 0;
}
