#include <bits/stdc++.h>
using namespace std;
const static int inf = 10000000;
const static int mod = 1000000007;
int check(const vector<string>& s, const vector<string>& t) {
  int n = s.size();
  vector<int> idx(n);
  for (int i = 0; i < (int)(n); i++) {
    idx[i] = i;
  }
  int ret = 0;
  do {
    vector<string> ss(n);
    for (int i = 0; i < (int)(n); i++) {
      ss[i] = s[idx[i]];
    }
    int pos = 0;
    for (int i = 0; i < t.size() && pos < s.size(); ++i) {
      if (ss[pos] == t[i]) {
        ++pos;
      }
    }
    if (pos != s.size()) {
      continue;
    }
    int inv = 0;
    for (int i = 0; i < (int)(n); i++) {
      for (int j = i + 1; j < n; ++j) {
        if (idx[i] > idx[j]) {
          ++inv;
        }
      }
    }
    int buf = n * (n - 1) / 2 - inv + 1;
    ret = max(ret, buf);
  } while (next_permutation((idx).begin(), (idx).end()));
  return ret;
}
int main() {
  int n;
  while (cin >> n) {
    vector<string> s(n);
    for (int i = 0; i < (int)(n); i++) {
      cin >> s[i];
    }
    int mxp = 0;
    int idx = -1;
    int k;
    cin >> k;
    for (int i = 0; i < (int)(k); i++) {
      int m;
      cin >> m;
      vector<string> t(m);
      for (int j = 0; j < (int)(m); j++) {
        cin >> t[j];
      }
      int p = check(s, t);
      if (p > mxp) {
        mxp = p;
        idx = i;
      }
    }
    if (idx == -1) {
      cout << "Brand new problem!" << endl;
    } else {
      cout << idx + 1 << endl;
      cout << "[:";
      for (int i = 0; i < (int)(mxp); i++) {
        cout << "|";
      }
      cout << ":]" << endl;
    }
  }
  return 0;
}
