#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAX = 1000000007;
const int MAXN = 17;
const int MAXM = 500007;
const int MAXSL = 13;
const int MAXS = (1 << 15) + 7;
const int MUL = 27;
int n, m, q;
char buf[MAXSL];
map<unsigned long long, int> hmp;
map<unsigned long long, int>::iterator mpit;
int b[MAXM];
int dpx[MAXN][MAXS], dpy[MAXN][MAXS];
int fdp[MAXS];
int tc[MAXS];
int stk[MAXS], top;
void init();
void input();
void inputq();
void work();
unsigned long long gethsh(char s[]) {
  int len = strlen(s);
  unsigned long long ans = 0;
  for (int i = 0; i < len; ++i) ans = ans * MUL + (s[i] - 'a' + 1);
  return ans;
}
int getans();
void dps(int lv, int l, int r, int dp[]);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%s", buf), hmp.insert(make_pair(gethsh(buf), n - i));
  scanf("%d", &q);
}
void inputq() {
  int tm;
  scanf("%d", &tm);
  m = 0;
  unsigned long long nh;
  for (int i = 1; i <= tm; ++i) {
    scanf("%s", buf);
    nh = gethsh(buf);
    if ((mpit = hmp.find(nh)) != hmp.end()) b[++m] = mpit->second;
  }
}
void work() {
  int ansid = -1, ansmax = -1, curans;
  for (int _q = 1; _q <= q; ++_q) {
    inputq();
    curans = getans();
    if (curans > ansmax) ansmax = curans, ansid = _q;
  }
  if (ansid == -1) {
    printf("Brand new problem!\n");
  } else {
    printf("%d\n", ansid);
    printf("[:");
    for (int i = 0; i < ansmax; ++i) putchar('|');
    printf(":]\n");
  }
}
int getans() {
  dps(n - 1, 1, m, fdp);
  return (n * (n - 1) >> 1) - fdp[(1 << n) - 1] + 1;
}
void dps(int lv, int l, int r, int dp[]) {
  int ms = (1 << (lv + 1));
  dp[0] = 0;
  for (int i = 1; i < ms; ++i) dp[i] = MAX;
  if (l > r) return;
  int *dx = dpx[lv], *dy = dpy[lv];
  int np = -1;
  for (int i = l; i <= r; ++i) {
    if (b[i] == lv) {
      np = i;
      break;
    }
  }
  if (!lv) {
    dp[0] = 0;
    dp[1] = (~np) ? 0 : MAX;
    return;
  }
  if (np == -1) {
    dps(lv - 1, l, r, dx);
    int vms = 1 << lv;
    for (int i = 0; i < vms; ++i) dp[i] = dx[i];
    return;
  }
  dps(lv - 1, l, np - 1, dx);
  dps(lv - 1, np + 1, r, dy);
  int vms = 1 << lv, rs, j, lb, pv;
  for (int i = 0; i < vms; ++i) {
    rs = (vms - 1) ^ i;
    top = 0;
    for (int j = rs;; j = (j - 1) & rs) {
      stk[++top] = j;
      if (!j) break;
    }
    tc[0] = 0;
    for (int ntop = top; ntop > 0; --ntop) {
      j = stk[ntop];
      if (j) {
        lb = j & -j;
        tc[j] = tc[j ^ lb] + __builtin_popcount(i & (lb - 1));
      }
      pv = dx[i] + dy[j] + tc[j];
      dp[i | j] = (((dp[i | j]) < (pv)) ? (dp[i | j]) : (pv));
      dp[i | j | vms] = (((dp[i | j | vms]) < (pv + __builtin_popcount(i)))
                             ? (dp[i | j | vms])
                             : (pv + __builtin_popcount(i)));
    }
  }
}
