#include <bits/stdc++.h>
const int maxn = 16;
const int maxbitmap = 33000;
const int maxlen = 12;
const int maxinvnum = maxn * (maxn - 1) / 2;
const int maxge = 500010;
int mi[maxn + 1], a[maxge + 1], f[maxbitmap + 1][maxinvnum + 1],
    yh[maxbitmap][maxn + 1], next[maxge + 1][maxn + 1];
int bestid, bestval, n, ge, nowmaxinv;
char myprob[maxn + 1][maxlen + 1];
void init() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%s", myprob[i]);
  mi[0] = 1;
  for (i = 1; i <= n; ++i) mi[i] = mi[i - 1] * 2;
  for (i = 0; i < mi[n]; ++i)
    for (j = 1; j <= n; ++j)
      if (!(i & mi[j - 1])) {
        yh[i][j] = 0;
        for (k = j + 1; k <= n; ++k)
          if (i & mi[k - 1]) ++yh[i][j];
      }
  nowmaxinv = n * (n - 1) / 2;
}
void DP() {
  int i, j, k;
  for (i = 0; i < mi[n]; ++i)
    for (j = 0; j <= nowmaxinv; ++j) f[i][j] = -1;
  f[0][0] = 0;
  for (i = 0; i < mi[n]; ++i)
    for (j = 0; j <= nowmaxinv; ++j)
      if (f[i][j] != -1) {
        for (k = 1; k <= n; ++k)
          if (!(i & mi[k - 1]))
            if (next[f[i][j] + 1][k] <= ge)
              if ((f[i + mi[k - 1]][j + yh[i][k]] == -1) ||
                  (next[f[i][j] + 1][k] < f[i + mi[k - 1]][j + yh[i][k]])) {
                f[i + mi[k - 1]][j + yh[i][k]] = next[f[i][j] + 1][k];
              }
      }
}
void work() {
  int i, j, k, m, oldge;
  char word[maxlen + 1];
  bestval = -1;
  scanf("%d", &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d", &oldge);
    ge = 0;
    for (j = 1; j <= oldge; ++j) {
      scanf("%s", word);
      for (k = 1; k <= n; ++k)
        if (strcmp(word, myprob[k]) == 0) break;
      if (k <= n) a[++ge] = k;
    }
    for (j = 1; j <= n; ++j) next[ge + 1][j] = ge + 1;
    for (j = ge; j >= 1; --j) {
      for (k = 1; k <= n; ++k) next[j][k] = next[j + 1][k];
      next[j][a[j]] = j;
    }
    DP();
    for (j = 0; j <= nowmaxinv; ++j)
      if (f[mi[n] - 1][j] != -1) {
        if ((bestval == -1) || (nowmaxinv - j + 1 > bestval)) {
          bestval = nowmaxinv - j + 1;
          bestid = i;
        }
        break;
      }
  }
}
void output() {
  int i;
  if (bestval == -1)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", bestid);
    printf("[:");
    for (i = 1; i <= bestval; ++i) printf("|");
    printf(":]\n");
  }
}
int main() {
  init();
  work();
  output();
  return 0;
}
