#include <bits/stdc++.h>
using namespace std;
int idx = 1 << 30;
set<string> Set;
vector<string> v1;
vector<vector<string> > arch;
vector<string> vs;
int sim = 1 << 30;
int totalinv = 1 << 30;
vector<vector<string> > modes;
int inv(vector<string> t) {
  int cnt = 0;
  for (int i = 0; i < v1.size(); i++) {
    for (int j = i + 1; j < v1.size(); j++) {
      int k1, k2;
      for (int k = 0; k < v1.size(); k++) {
        if (t[k] == vs[i]) k1 = k;
        if (t[k] == vs[j]) k2 = k;
      }
      if (k1 > k2) {
        cnt++;
      }
    }
  }
  return cnt;
}
bool isSub(vector<string> v1, vector<string> v2) {
  int K = 0;
  for (int i = 0; i < v1.size();) {
    if (K >= v2.size()) return false;
    if (v1[i] == v2[K]) {
      i += 1;
      K += 1;
    } else
      K += 1;
  }
  return true;
}
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    Set.insert(t);
    v1.push_back(t);
    vs.push_back(t);
  }
  sort(v1.begin(), v1.end());
  do {
    modes.push_back(v1);
  } while (next_permutation(v1.begin(), v1.end()));
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int l;
    cin >> l;
    vector<string> temp;
    for (int j = 0; j < l; j++) {
      string t;
      cin >> t;
      temp.push_back(t);
    }
    arch.push_back(temp);
  }
  for (int i = 0; i < modes.size(); i++) {
    for (int j = 0; j < arch.size(); j++) {
      if (isSub(modes[i], arch[j])) {
        int iv = inv(modes[i]);
        if (iv == totalinv) {
          idx = min(j, idx);
        }
        if (iv < totalinv) {
          idx = j;
          totalinv = iv;
          sim = ((modes[i].size() * (modes[i].size() - 1)) / 2) - iv + 1;
        }
      }
    }
  }
  if (sim == (1 << 30)) {
    cout << "Brand new problem!" << endl;
  } else {
    cout << idx + 1 << endl;
    cout << "[:";
    for (int i = 0; i < sim; i++) cout << "|";
    cout << ":]" << endl;
  }
  return 0;
}
