#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const int M = 16;
const int inf = 0x3f3f3f3f;
const int S = 1 << 15;
map<string, int> mp;
int vs[15], n, m;
char s[N][12], sx[12];
int dp[S], cnt[S][16];
int cal(int st) {
  int res = 0;
  while (st) {
    if (st & 1) res++;
    st >>= 1;
  }
  return res;
}
void prepare() {
  for (int i = 0; i < S; ++i) {
    int tmp = i;
    for (int j = 0; j < M; ++j) {
      tmp >>= 1;
      cnt[i][j] = cal(tmp);
    }
  }
}
int stx[N], pre[M];
int main() {
  prepare();
  ios::sync_with_stdio(0);
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", sx);
    mp[sx] = i;
  }
  int ans1 = -1, ans2 = 0, ans3 = 0;
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int k;
    scanf("%d", &k);
    memset(vs, 0, sizeof vs);
    for (int j = 0; j < k; ++j) {
      scanf("%s", s[j]);
      if (mp.find(s[j]) == mp.end()) continue;
      vs[mp[s[j]]] = 1;
    }
    int f = 0;
    for (int j = 0; j < n && !f; ++j)
      if (!vs[j]) f = 1;
    if (f) continue;
    int v = 0;
    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;
    int pre = 0;
    for (int j = 0; j < k; ++j) {
      if (mp.find(s[j]) == mp.end()) continue;
      int id = mp[s[j]], vst = 1 << id;
      if (pre & (1 << id)) continue;
      pre = (pre & ((1 << id) - 1) | (1 << id));
      for (int st = stx[j] & (vst - 1); st < (1 << n); ++st)
        if ((st & vst) == 0) {
          dp[st | vst] = min(dp[st | vst], dp[st] + cnt[st][id]);
        }
    }
    int tmp = n * (n - 1) / 2 - dp[(1 << n) - 1] + 1;
    if (ans1 == -1 || tmp > ans2 || (tmp == ans2 && dp[(1 << n) - 1] < ans3)) {
      ans1 = i;
      ans2 = tmp;
      ans3 = dp[(1 << n) - 1];
    }
  }
  if (ans1 == -1)
    puts("Brand new problem!");
  else {
    printf("%d\n", ans1 + 1);
    printf("%s", "[:");
    for (int i = 0; i < ans2; ++i) putchar('|');
    puts(":]");
  }
  return 0;
}
