#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  string word[5];
  string in[22];
  cin >> n;
  int sol = -1;
  int solsim = -1;
  for (int i = 0; i < n; i++) {
    cin >> word[i];
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) cin >> in[j];
    int perm[5];
    for (int j = 0; j < n; j++) {
      perm[j] = j;
    }
    int mininv = -1;
    do {
      int p = 0;
      for (int j = 0; j < k && p < n; j++) {
        if (word[perm[p]] == in[j]) p++;
      }
      if (p < n) continue;
      int inv = 0;
      for (int j = 0; j < n; j++) {
        for (int l = j + 1; l < n; l++) {
          if (perm[j] > perm[l]) inv++;
        }
      }
      if (mininv == -1 || inv < mininv) mininv = inv;
    } while (next_permutation(perm, perm + n));
    if (mininv == -1) continue;
    int sim = (n * (n - 1)) / 2 - mininv + 1;
    if (solsim == -1 || solsim < sim) {
      sol = i + 1;
      solsim = sim;
    }
  }
  if (sol == -1) {
    cout << "Brand new problem!" << endl;
  } else {
    cout << sol << endl;
    cout << "[:";
    for (int j = 0; j < solsim; j++) cout << "|";
    cout << ":]" << endl;
  }
  return 0;
}
