#include <bits/stdc++.h>
using namespace std;
const int N = 21;
char pb[N][N], archive[N][N];
int sol[N], Psize, Asize, nrbest, valbest, val, nr;
bool use[N];
bool match(char a[], char b[]) {
  for (int i = 0; a[i] || b[i]; i++)
    if (a[i] != b[i]) return false;
  return true;
}
int nr_inv(int v[]) {
  int nr = 0;
  for (int i = 1; i < Psize; i++)
    for (int j = i + 1; j <= Psize; j++)
      if (v[i] > v[j]) nr++;
  return nr;
}
void bkt(int p) {
  if (p == Psize + 1) {
    val = Psize * (Psize - 1) / 2 - nr_inv(sol) + 1;
    if (valbest < val) {
      valbest = val;
      nrbest = nr;
    }
    return;
  }
  for (int i = 1; i <= Asize; i++)
    if (!use[i] && match(archive[i], pb[p])) {
      use[i] = true;
      sol[p] = i;
      bkt(p + 1);
      use[i] = false;
    }
}
void standard() {}
void get(char s[N][N], int& n) {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> s[i];
}
void print_sol(int a, int b) {
  if (!b) {
    cout << "Brand new problem!\n";
    return;
  }
  cout << a << "\n[:";
  while (b--) cout << "|";
  cout << ":]\n";
}
int main() {
  standard();
  get(pb, Psize);
  int m;
  cin >> m;
  for (nr = 1; nr <= m; nr++) {
    get(archive, Asize);
    bkt(1);
  }
  print_sol(nrbest, valbest);
  return 0;
}
