#include <bits/stdc++.h>
using namespace std;
const int mod = 10000019;
int N;
int M;
string S[(15)];
int H[(15)];
vector<int> V;
vector<int> cn[(15)];
int dp[(32768)][(108)];
int hash1(string s) {
  int h = 0;
  int sz = s.length();
  for (int i = 0; i < sz; ++i) h = ((26 * h) + (s[i] - 'a')) % mod;
  return h;
}
int main() {
  int i, j, k;
  scanf("%d", &N);
  for (i = 0; i < N; ++i) {
    char s[(16)];
    scanf("%s", s);
    S[i] = s;
    H[i] = hash1(S[i]);
  }
  int sol = -1;
  int soli;
  int n2 = (N * (N - 1)) >> 1;
  int np2 = 1 << N;
  for (k = 0; k < N; ++k) cn[k] = vector<int>((500005), -1);
  scanf("%d", &M);
  for (i = 0; i < M; ++i) {
    int K;
    scanf("%d", &K);
    V.resize(K);
    if (i) {
      for (k = 0; k < N; ++k)
        memset(&cn[k][0], -1, cn[k].end() - cn[k].begin());
    }
    for (j = 0; j < K; ++j) {
      char s1[(16)];
      scanf("%s", s1);
      string s = s1;
      int h = hash1(s);
      int m = 0;
      for (k = 0; k < N; ++k) {
        if (H[k] == h && s.length() == S[k].length()) {
          cn[k][j] = j;
          V[j] = k;
          m = 1;
          break;
        }
      }
      if (m == 0) V[j] = -1;
    }
    for (k = 0; k < N; ++k) {
      int last = -1;
      for (j = K - 1; j >= 0; --j) {
        if (cn[k][j] != -1)
          last = cn[k][j];
        else
          cn[k][j] = last;
      }
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    int iv;
    int b;
    for (b = 0; b < np2; ++b) {
      for (iv = 0; iv <= n2; ++iv) {
        int d = dp[b][iv];
        if (d == -1 || d == K) continue;
        int iv1 = iv;
        int b1 = b;
        for (j = 0; j < N; ++j) {
          if ((b1 & 1) == 0) {
            if (cn[j][d] != -1) {
              int b2 = b | (1 << j);
              int d2 = cn[j][d] + 1;
              int &d3 = dp[b2][iv1];
              if (d3 == -1 || d3 > d2) {
                d3 = d2;
              }
            }
            ++iv1;
          }
          b1 >>= 1;
        }
      }
    }
    for (iv = 0; iv <= n2; ++iv) {
      if (dp[np2 - 1][iv] != -1) {
        if (sol == -1 || sol > iv) {
          sol = iv;
          soli = i;
        }
        break;
      }
    }
  }
  if (sol == -1)
    printf("Brand new problem!\n");
  else {
    sol = n2 - sol + 1;
    printf("%d\n", soli + 1);
    printf("[:");
    for (i = 0; i < sol; ++i) putchar('|');
    printf(":]\n");
  }
  return 0;
}
