#include <bits/stdc++.h>
using namespace std;
const int iinf = 1e9 + 1e6 + 1e3;
const double eps = 1e-6;
const int N = 16;
const int M = 5e5 + 1e3;
int target[N][M];
int dp[1 << N];
int len[N];
map<string, int> mp;
int n, m;
int ind, ans;
void readinAim() {
  scanf("%d", &n);
  char tmp[N];
  for (int i = 1; i <= n; i++) {
    scanf("%s", tmp);
    string ss = tmp;
    mp[ss] = i;
  }
  return;
}
void readinTarget() {
  scanf("%d", &m);
  memset(len, 0, sizeof(len));
  char tmp[N];
  memset(target, -1, sizeof(target));
  for (int i = 1; i <= m; i++) {
    int k;
    scanf("%d", &k);
    len[i] = k;
    for (int j = 1; j <= k; j++) {
      scanf("%s", tmp);
      string ss = tmp;
      int tmp = mp[ss];
      if (tmp) target[i][j] = tmp - 1;
    }
  }
  return;
}
int cntbt(int x) {
  int cnt = 0;
  while (x) {
    cnt += (x & 1);
    x >>= 1;
  }
  return cnt;
}
void solve() {
  ans = iinf;
  int maxn = (1 << n);
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < maxn; j++) dp[j] = iinf;
    dp[0] = 0;
    int pre = 0;
    for (int j = 1; j <= len[i]; j++) {
      if (target[i][j] < 0) continue;
      if (pre & (1 << target[i][j])) continue;
      for (int k = 0; k < maxn; k++) {
        if (dp[k] > 1e9) continue;
        int to = (k | (1 << target[i][j]));
        pre = (pre & (1 << target[i][j]) - 1) | (1 << target[i][j]);
        dp[to] = min(dp[to], dp[k] + cntbt(k >> target[i][j]));
      }
    }
    if (dp[maxn - 1] < ans) {
      ans = dp[maxn - 1];
      ind = i;
    }
  }
  return;
}
int main() {
  mp.clear();
  readinAim();
  readinTarget();
  solve();
  if (ans == iinf) {
    printf("Brand new problem!\n");
  } else {
    int p = (n * (n - 1)) / 2 - ans + 1;
    printf("%d\n", ind);
    printf("[:");
    for (int i = 1; i <= p; i++) printf("|");
    printf(":]");
  }
  return 0;
}
