#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 15;
const int NBITS = 1 << MAX_N;
const int MAX_K = 500000;
const int MAX_X = MAX_N * (MAX_N - 1) / 2;
const int INF = 1 << 30;
int bnums[NBITS], ass[MAX_N][MAX_K], ans[MAX_N], bs[MAX_K], rbs[MAX_K + 1];
map<string, int> smap;
int dp[NBITS][MAX_X + 1];
int main() {
  int n;
  scanf("%d", &n);
  int nbits = 1 << n, nmsk = nbits - 1;
  bnums[0] = 0;
  for (int bits = 1, msb = 1; bits < nbits; bits++) {
    if ((msb << 1) <= bits) msb <<= 1;
    bnums[bits] = bnums[bits ^ msb] + 1;
  }
  for (int i = 0; i < n; i++) {
    char s[16];
    scanf("%s", s);
    smap[string(s)] = i;
  }
  int m;
  scanf("%d", &m);
  int maxx = n * (n - 1) / 2;
  int minx = INF, miny = -1;
  for (int y = 0; y < m; y++) {
    int k;
    scanf("%d", &k);
    memset(ans, 0, sizeof(ans));
    int l = 0;
    for (int i = 0; i < k; i++) {
      char s[16];
      scanf("%s", s);
      map<string, int>::iterator mit = smap.find(string(s));
      if (mit != smap.end()) {
        int j = mit->second;
        bs[l] = j;
        ass[j][ans[j]++] = l++;
      }
    }
    rbs[l] = 0;
    for (int i = l - 1; i >= 0; i--) rbs[i] = rbs[i + 1] | (1 << bs[i]);
    if (rbs[0] != nmsk) continue;
    for (int bits = 0; bits < nbits; bits++)
      fill(dp[bits], dp[bits] + maxx + 1, INF);
    dp[0][0] = 0;
    for (int bits = 0; bits < nbits; bits++)
      for (int x = 0; x <= maxx; x++)
        if (dp[bits][x] < l)
          for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
            if (!(bits & bi)) {
              int j =
                  lower_bound(ass[i], ass[i] + ans[i], dp[bits][x]) - ass[i];
              if (j < ans[i]) {
                int bitsi = bits | bi;
                int xi = x + bnums[bits & ~(bi - 1)];
                int d = ass[i][j] + 1;
                if ((bitsi | rbs[d]) == nmsk && dp[bitsi][xi] > d)
                  dp[bitsi][xi] = d;
              }
            }
    for (int x = 0; x <= maxx && x < minx; x++)
      if (dp[nmsk][x] < INF) minx = x, miny = y;
  }
  if (minx >= INF)
    puts("Brand new problem!");
  else {
    int p = n * (n - 1) / 2 - minx + 1;
    printf("%d\n[:", miny + 1);
    for (int i = 0; i < p; i++) putchar('|');
    puts(":]");
  }
  return 0;
}
