#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
vector<string> token(string s) {
  vector<string> ans;
  stringstream ss(s);
  string tmp;
  while (ss >> tmp) ans.push_back(tmp);
  return ans;
}
bool issub(vector<string> vs1, vector<string> vs2) {
  int lastj = 0;
  for (int i = 0; i < (int)vs1.size(); ++i) {
    for (int j = lastj; j < (int)vs2.size(); ++j, lastj++) {
      if (vs1[i] == vs2[j]) goto out;
    }
    return false;
  out:;
  }
  return true;
}
map<string, int> idx;
int match(vector<string> lsv, vector<string> asv) {
  sort(lsv.begin(), lsv.end());
  int Mx = oo;
  int p = -1;
  do {
    if (issub(lsv, asv)) {
      int x = 0;
      for (int i = 0; i < (int)lsv.size(); ++i) {
        for (int j = i + 1; j < (int)lsv.size(); ++j) {
          if (idx[lsv[i]] > idx[lsv[j]]) x++;
        }
      }
      if (x < Mx) {
        Mx = x;
        p = ((int)lsv.size() * ((int)lsv.size() - 1)) / 2 - x + 1;
      }
    }
  } while (next_permutation(lsv.begin(), lsv.end()));
  return p;
}
int main() {
  int n;
  cin >> n;
  vector<string> lsw(n);
  for (int i = 0; i < n; ++i) {
    cin >> lsw[i];
    idx[lsw[i]] = i;
  }
  int N;
  cin >> N;
  vector<vector<string> > arch(N);
  for (int i = 0; i < N; ++i) {
    int cnt;
    cin >> cnt;
    for (int j = 0; j < cnt; ++j) {
      string tmp;
      cin >> tmp;
      arch[i].push_back(tmp);
    }
  }
  bool flg = false;
  int ans = 0;
  int id = -1;
  for (int i = 0; i < N; ++i) {
    int res = match(lsw, arch[i]);
    if (res != -1) {
      flg = true;
      if (ans < res) {
        ans = res;
        id = i;
      }
    }
  }
  if (!flg) {
    cout << "Brand new problem!" << endl;
    return 0;
  }
  cout << id + 1 << endl;
  cout << "[:";
  for (int i = 0; i < ans; ++i) {
    cout << "|";
  }
  cout << ":]";
  return 0;
}
