#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
map<string, int> lesha;
vector<int> v;
int nxt[500035][16], sz, w[1 << 15][16];
const int maxk = 110;
int dp[1 << 15][maxk];
void ii() {
  for (int s = 0; s < (1 << n); s++) {
    for (int j = 1; j <= n; j++) {
      int x = (1 << n) - 1 - ((1 << j) - 1);
      w[s][j] = __builtin_popcount(x & s);
    }
  }
}
void init() {
  sz = (int)v.size();
  for (int(i) = 0; (i) < (int)(sz + 1); (i)++)
    for (int(j) = 0; (j) < (int)(n + 1); (j)++) nxt[i][j] = 1 << 30;
  for (int i = sz - 1; i >= 0; i--) {
    for (int j = 1; j <= n; j++) nxt[i][j] = nxt[i + 1][j];
    nxt[i][v[i]] = i + 1;
  }
}
int cal() {
  init();
  for (int(i) = 0; (i) < (int)(1 << n); (i)++)
    for (int(k) = 0; (k) < (int)(maxk); (k)++) dp[i][k] = 1 << 30;
  dp[0][0] = 0;
  dp[1 << (v[0] - 1)][0] = 1;
  for (int s = 0; s < (1 << n); s++) {
    for (int k = 0; k < maxk; k++)
      for (int x = 1; x <= n; x++)
        if (dp[s][k] < 1 << 30 && k + w[s][x] < maxk) {
          int tmp = dp[s | (1 << (x - 1))][k + w[s][x]];
          dp[s | (1 << (x - 1))][k + w[s][x]] = min(tmp, nxt[dp[s][k]][x]);
        }
  }
  for (int k = 0; k < maxk; k++)
    if (dp[(1 << n) - 1][k] != 1 << 30) {
      return k;
    }
  return 1 << 30;
}
int main() {
  scanf("%d", &n);
  string tmp;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    cin >> tmp;
    lesha[tmp] = i + 1;
  }
  scanf("%d", &m);
  ii();
  int ans = 1 << 30;
  int aa = 0;
  for (int(i) = 0; (i) < (int)(m); (i)++) {
    scanf("%d", &k);
    v.clear();
    for (int(j) = 0; (j) < (int)(k); (j)++) {
      cin >> tmp;
      if (lesha.find(tmp) != lesha.end()) {
        v.push_back(lesha[tmp]);
      }
    }
    if (v.empty()) continue;
    int tt = cal();
    if (tt < ans) {
      ans = tt;
      aa = i + 1;
    }
  }
  if (!aa)
    puts("Brand new problem!");
  else {
    int count = (n - 1) * n / 2 - ans + 1;
    printf("%d\n", aa);
    printf("[:");
    for (int(i) = 0; (i) < (int)(count); (i)++) printf("|");
    puts(":]");
  }
  return 0;
}
