#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
int aa[N], top;
int ww[1 << 15][15];
int s[15], id[15];
int _next[N][15];
int dp[1 << 15][15 * 15];
map<string, int> mp;
int main() {
  int n;
  for (int i = 0; i < 15; i++) s[i] = 1 << i;
  for (int i = 0; i < (1 << 15); i++) {
    for (int j = 0; j < 15; j++) {
      ww[i][j] = 0;
      int ii = i >> (j + 1);
      while (ii) {
        ww[i][j]++;
        ii -= ii & -ii;
      }
    }
  }
  while (scanf("%d", &n) != EOF) {
    string ss;
    mp.clear();
    for (int i = 0; i < n; i++) {
      cin >> ss;
      mp[ss] = i + 1;
    }
    int m;
    scanf("%d", &m);
    int ans = n * n, idx = -1;
    for (int i = 0; i < m; i++) {
      int k;
      scanf("%d", &k);
      top = 1;
      aa[0] = 0;
      for (int j = 0; j < k; j++) {
        cin >> ss;
        int t = mp[ss];
        if (t == 0) continue;
        aa[top++] = t - 1;
      }
      if (top - 1 < n) continue;
      for (int j = 0; j < n; j++) id[j] = top;
      for (int j = top - 1; j >= 0; j--) {
        for (int j1 = 0; j1 < n; j1++) {
          _next[j][j1] = id[j1];
        }
        id[aa[j]] = j;
      }
      memset(dp, 0x3f, sizeof(dp));
      dp[0][0] = 0;
      int ed = 1 << n;
      for (int j = 0; j < ed; j++) {
        for (int w = 0; w < n * n; w++)
          if (dp[j][w] < top) {
            for (int j1 = 0; j1 < n; j1++)
              if (_next[dp[j][w]][j1] < top && (j & s[j1]) == 0) {
                dp[j | s[j1]][w + ww[j][j1]] =
                    min(dp[j | s[j1]][w + ww[j][j1]], _next[dp[j][w]][j1]);
              }
          }
      }
      for (int w = 0; w < n * n; w++) {
        if (dp[ed - 1][w] < top) {
          if (w < ans) {
            ans = w;
            idx = i;
          }
        }
      }
    }
    if (ans < n * n) {
      printf("%d\n", idx + 1);
      ans = n * (n - 1) / 2 - ans + 1;
      printf("[:");
      for (int i = 0; i < ans; i++) printf("|");
      printf(":]\n");
    } else
      printf("Brand new problem!\n");
  }
  return 0;
}
