#include <bits/stdc++.h>
using namespace std;
vector<string> lesha;
vector<int> perm;
vector<pair<vector<int>, int> > perms;
int n;
int inv(vector<int> p) {
  int res = 0;
  for (int i = 0; i < p.size(); ++i)
    for (int j = i + 1; j < p.size(); ++j)
      if (p[i] > p[j]) ++res;
  return res;
}
bool pos(int cur, int a) {
  for (int i = 0; i < cur; ++i)
    if (perm[i] == a) return false;
  return true;
}
void next(int cur) {
  if (cur == n) {
    perms.push_back(make_pair(perm, inv(perm)));
    return;
  }
  for (int i = 0; i < n; ++i)
    if (pos(cur, i)) {
      perm[cur] = i;
      next(cur + 1);
    }
}
int f(int N, int x) { return N * (N - 1) / 2 - x + 1; }
int eqv(vector<string> s) {
  int res = -1;
  for (int i = 0; i < perms.size(); ++i) {
    int cur = 0;
    for (int j = 0; j < s.size(); ++j)
      if (s[j] == lesha[perms[i].first[cur]]) {
        ++cur;
        if (cur == n) {
          res = max(res, f(n, perms[i].second));
          break;
        }
      }
  }
  return res;
}
int main() {
  cin >> n;
  lesha.resize(n);
  perm.resize(n);
  for (int i = 0; i < n; ++i) cin >> lesha[i];
  int m, k, res = -1, best = 0;
  cin >> m;
  next(0);
  for (int i = 0; i < m; ++i) {
    cin >> k;
    vector<string> s(k);
    for (int j = 0; j < k; ++j) cin >> s[j];
    int cur = eqv(s);
    if (cur > res) {
      res = cur;
      best = i;
    }
  }
  if (res == -1)
    cout << "Brand new problem!" << endl;
  else {
    cout << best + 1 << endl;
    cout << "[:";
    for (int i = 0; i < res; ++i) cout << "|";
    cout << ":]" << endl;
  }
  return 0;
}
