#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
map<string, int> mp;
vector<vector<int> > b;
int m;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    mp[tmp] = i + 1;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int t;
    vector<int> vs;
    cin >> t;
    for (int j = 0; j < t; j++) {
      string tmp;
      cin >> tmp;
      if (mp.find(tmp) != mp.end()) vs.push_back(mp[tmp]);
    }
    b.push_back(vs);
  }
  int res = -1;
  int sim = -100;
  for (int i = 0; i < m; i++) {
    vector<int> vs = b[i];
    a.clear();
    for (int j = 1; j <= n; j++) a.push_back(j);
    do {
      int x = 0;
      int y = 0;
      while (x < n && y < (int)vs.size()) {
        if (a[x] == vs[y]) {
          x++;
          y++;
        } else
          y++;
      }
      if (x == n) {
        int tsim = n * (n - 1) / 2 + 1;
        int inv = 0;
        for (int x = 0; x < n; x++) {
          for (int y = x + 1; y < n; y++) {
            if (a[x] > a[y]) inv++;
          }
        }
        tsim -= inv;
        if (tsim > sim) {
          sim = tsim;
          res = i + 1;
        }
      }
    } while (next_permutation(a.begin(), a.end()));
  }
  if (res == -1) {
    cout << "Brand new problem!" << endl;
  } else {
    cout << res << endl;
    cout << "[:";
    for (int i = 0; i < sim; i++) cout << "|";
    cout << ":]" << endl;
  }
  return 0;
}
