#include <bits/stdc++.h>
using namespace std;
int n, m;
int fact = 1;
string s[10], t[10];
int get_invnum(int *a) {
  register int i, j;
  int cnt = 0;
  for (i = 0; i < n; ++i)
    for (j = i + 1; j < n; ++j)
      if (a[j] < a[i]) cnt++;
  return cnt;
}
bool matched(string *a, string *b, int len) {
  register int i;
  int pos = 0;
  for (i = 0; i < len; ++i) {
    if (b[i] == a[pos]) pos++;
    if (pos == n) return true;
  }
  return false;
}
int get_sim() {
  register int i, k;
  int len, ans = 0, per[10];
  string tmp[20];
  scanf("%d", &len);
  for (i = 0; i < len; ++i) cin >> tmp[i];
  for (i = 0; i < n; ++i) per[i] = i;
  for (k = 0; k < fact; ++k, next_permutation(per, per + n)) {
    for (i = 0; i < n; ++i) t[i] = s[per[i]];
    if (!matched(t, tmp, len)) continue;
    ans = max(ans, n * (n - 1) / 2 + 1 - get_invnum(per));
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  register int i;
  for (i = 0; i < n; ++i) cin >> s[i];
  for (i = 1; i <= n; ++i) fact *= i;
  scanf("%d", &m);
  int ans = 0, ansid = 0;
  for (i = 0; i < m; ++i) {
    int sim_val = get_sim();
    if (sim_val > ans) {
      ans = sim_val;
      ansid = i + 1;
    }
  }
  if (!ans) {
    printf("Brand new problem!\n");
    return 0;
  }
  cout << ansid << "\n[:";
  while (ans--) cout << "|";
  cout << ":]\n";
  return 0;
}
