#include <bits/stdc++.h>
const double pi = 3.1415926535897932384626433832795;
#pragma comment(linker, "/stack:1000000000")
int gcd(int a, int b) { return !a ? b : gcd(b % a, a); }
using namespace std;
vector<string> init, tmp, tmp2, init2;
vector<pair<int, int> > ans;
map<string, int> posi;
int n, m, t;
int main() {
  cin >> n;
  init.resize(n);
  for (int i = (0); i < (n); ++i) {
    cin >> init[i];
    posi[init[i]] = i;
  }
  cin >> m;
  for (int i = (0); i < (m); ++i) {
    cin >> t;
    tmp.clear();
    tmp2.clear();
    init2 = init;
    sort((init2).begin(), (init2).end());
    tmp.resize(t);
    for (int j = (0); j < (t); ++j) cin >> tmp[j];
    int bestp = 100000;
    bool ok = false;
    do {
      int pos1 = 0, pos2 = 0, pp = 0;
      while (pos1 < init.size() && pos2 < t) {
        if (init2[pos1] == tmp[pos2]) {
          pos1++;
          pos2++;
        } else {
          pos2++;
        }
      }
      if (pos1 == init.size()) {
        ok = true;
        int cnt = 0;
        for (int i = (0); i < (n); ++i)
          for (int j = (0); j < (i); ++j)
            if (posi[init2[j]] > posi[init2[i]]) cnt++;
        bestp = ((bestp <= cnt) ? bestp : cnt);
      }
    } while (next_permutation((init2).begin(), (init2).end()));
    if (ok) {
      ans.push_back(make_pair(bestp, i + 1));
    }
  }
  if (!ans.size())
    cout << "Brand new problem!" << endl;
  else {
    sort((ans).begin(), (ans).end());
    int ansp = n * (n - 1) / 2 + 1 - ans[0].first;
    int bestn = 1000;
    for (int i = (0); i < (ans.size()); ++i)
      if (ans[i].first == ans[0].first)
        bestn = ((bestn <= ans[i].second) ? bestn : ans[i].second);
    cout << bestn << endl;
    cout << "[:";
    for (int i = (0); i < (ansp); ++i) cout << "|";
    cout << ":]" << endl;
  }
  return 0;
}
