#include <bits/stdc++.h>
using namespace std;
const int maxn = 15, inf = 111111, maxk = 5e5 + 10;
int dp[1 << maxn], n, m, ones[1 << maxn];
char s[maxn][maxn], t[maxn];
void init() {
  for (int i = 1; i < (1 << n) - 1; i++) ones[i] = ones[i >> 1] + (i & 1);
}
inline int slove() {
  int sz;
  scanf("%d", &sz);
  for (int i = 0; i < (1 << n); i++) dp[i] = inf;
  dp[0] = 0;
  int pre = 0;
  for (int i = 0; i < sz; i++) {
    scanf("%s", t);
    int p;
    for (p = 0; p < n; p++)
      if (!strcmp(s[p], t)) break;
    if (p >= n) continue;
    if (pre & (1 << p)) continue;
    pre = (pre & ((1 << p) - 1)) | (1 << p);
    for (int j = (1 << n) - 1; j >= 0; j--)
      if (dp[j] != inf && !(j & (1 << p))) {
        dp[j ^ (1 << p)] = min(dp[j ^ (1 << p)], dp[j] + ones[j >> p]);
      }
  }
  return dp[(1 << n) - 1];
}
int main() {
  scanf("%d", &n);
  init();
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  int ans = inf, pos;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int temp = slove();
    if (ans > temp) ans = temp, pos = i;
  }
  if (ans == inf)
    puts("Brand new problem!");
  else {
    printf("%d\n", pos);
    printf("[:");
    for (int i = 0; i < n * (n - 1) / 2 - ans + 1; i++) putchar('|');
    printf(":]\n");
  }
}
