#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
char buffer[100];
int nextint() {
  int t;
  scanf("%d", &t);
  return t;
}
string nextstring() {
  scanf("%s", buffer);
  return string(buffer);
}
map<string, int> s;
int nxt[500001][16];
int first[16];
int dp[(1 << 16)][8 * 15 + 1];
int bitcnt(int n) {
  int res = 0;
  while (n) {
    res += n & 1;
    n >>= 1;
  }
  return res;
}
int main() {
  int n = nextint();
  for (int i = 0; i < (n); i++) s[nextstring()] = i;
  int t = nextint();
  int res = -1;
  int resi = -1;
  for (int test = (1); test < (t + 1); test++) {
    int m = nextint();
    for (int i = 0; i < (m); i++)
      for (int j = 0; j < (n); j++) nxt[i][j] = INF;
    for (int i = 0; i < (n); i++) first[i] = INF;
    for (int i = 0; i < (m); i++) {
      string str = nextstring();
      if (s.find(str) != s.end()) {
        nxt[i][s[str]] = i;
        first[s[str]] = min(first[s[str]], i);
      }
    }
    for (int i = 0; i < (n); i++) {
      int prev = INF;
      for (int j = (m - 1); j > (-1); j--) {
        if (nxt[j][i] == j)
          swap(prev, nxt[j][i]);
        else
          nxt[j][i] = prev;
      }
    }
    int InvCnt = n * (n - 1) / 2;
    for (int i = 0; i < (1 << n); i++)
      for (int j = 0; j < (InvCnt + 1); j++) dp[i][j] = INF;
    for (int i = 0; i < (n); i++) dp[(1 << i)][0] = first[i];
    for (int i = 0; i < (1 << n); i++)
      for (int j = 0; j < (InvCnt + 1); j++) {
        if (dp[i][j] < INF) {
          int addcnt = bitcnt(i);
          for (int k = 0; k < (n); k++) {
            if (i & (1 << k)) {
              addcnt--;
            } else {
              dp[i | (1 << k)][j + addcnt] =
                  min(dp[i | (1 << k)][j + addcnt], nxt[dp[i][j]][k]);
            }
          }
        }
      }
    int val = INF;
    for (int j = 0; j < (InvCnt + 1); j++) {
      if (dp[(1 << n) - 1][j] < INF) {
        val = j;
        break;
      }
    }
    if (val == INF) continue;
    val = InvCnt - val + 1;
    if (res < val) {
      res = val;
      resi = test;
    }
    res = max(res, val);
  }
  if (res == -1) {
    puts("Brand new problem!");
  } else {
    printf("%d\n", resi);
    printf("[:");
    for (int i = 0; i < (res); i++) putchar('|');
    puts(":]");
  }
  return 0;
}
