#include <bits/stdc++.h>
using namespace std;
int M;
string a[16];
string b[500005];
int Next[500005][15];
int n, m, k, t, rst, r;
int d[1 << 15][15 * 15];
int what[1 << 15][15];
int main() {
  int i, j, cnt = 0;
  memset(d, 63, sizeof(d));
  M = d[0][0];
  for (i = 0; i < (1 << 15); i++) {
    for (j = 0; j < 15; j++) {
      cnt = 0;
      for (k = j + 1; k < 15; k++) {
        if ((i >> k) & 1) cnt++;
      }
      what[i][j] = cnt;
    }
  }
  for (i = 0, scanf("%d", &n); i < n; i++) cin >> a[i];
  rst = n * (n - 1) / 2 + 1;
  scanf("%d", &k);
  for (t = 1; t <= k; t++) {
    scanf("%d", &m);
    for (i = 1; i <= m; i++) cin >> b[i];
    for (i = 0; i < n; i++) Next[m + 1][i] = M;
    for (i = m; i >= 1; i--)
      for (j = 0; j < n; j++) {
        if (a[j] == b[i])
          Next[i][j] = i;
        else
          Next[i][j] = Next[i + 1][j];
      }
    memset(d, 63, sizeof(d));
    d[0][0] = 0;
    for (i = 0; i < (1 << n); i++)
      for (j = 0; j <= n * (n - 1) / 2; j++) {
        if (d[i][j] == M) continue;
        for (int use = 0; use < n; use++) {
          if ((i >> use) & 1) continue;
          int &p = d[i + (1 << use)][j + what[i][use]];
          p = min(p, Next[d[i][j] + 1][use]);
        }
      }
    for (i = 0; i < rst; i++)
      if (d[(1 << n) - 1][i] != M) {
        rst = i;
        r = t;
      }
  }
  rst = (n * (n - 1) / 2 + 1 - rst);
  if (rst == 0)
    printf("Brand new problem!");
  else {
    printf("%d\n[:", r);
    while (rst--) printf("|");
    printf(":]");
  }
  return 0;
}
