#include <bits/stdc++.h>
using namespace std;
string prob[25];
string lesha[5];
string orig[5];
int n, m;
int get_inv() {
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    for (int j = (i + 1); j < (n); j++) {
      int ii, jj;
      for (int l = 0; l < (n); l++) {
        if (orig[i] == lesha[l]) ii = l;
        if (orig[j] == lesha[l]) jj = l;
      }
      if (ii > jj) ans++;
    }
  }
  return (ans);
}
int main() {
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> lesha[i];
    orig[i] = lesha[i];
  }
  cin >> m;
  int k;
  int p = 0;
  int ind;
  for (int i = 0; i < (m); i++) {
    cin >> k;
    for (int j = 0; j < (k); j++) {
      cin >> prob[j];
    }
    sort(lesha, lesha + n);
    int pos[5];
    for (int j = 0; j < (n); j++) pos[j] = -1;
    do {
      int c = 0;
      int l = 0;
      int good = 0;
      while (l < n and c < k) {
        int j = c;
        for (; j < k; j++) {
          if (prob[j] == lesha[l]) {
            good++;
            break;
          }
        }
        c = j + 1;
        l++;
      }
      if (good == n) {
        int cnd = get_inv();
        cnd = (n * (n - 1)) / 2 - cnd + 1;
        if (cnd > p) {
          p = cnd;
          ind = i + 1;
        }
      }
    } while (next_permutation(lesha, lesha + n));
  }
  if (p) {
    cout << ind << endl;
    cout << "[:";
    for (int i = 0; i < (p); i++) cout << "|";
    cout << ":]" << endl;
  } else
    cout << "Brand new problem!" << endl;
  return 0;
}
