#include <bits/stdc++.h>
std::vector<std::string> prob;
std::vector<std::vector<std::string>> dict;
int n, m;
bool match(std::vector<int> const& v, int x) {
  int i = 0, t = 0;
  for (; i < n; i++) {
    bool find = false;
    for (; t < (int)dict[x].size(); t++)
      if (dict[x][t] == prob[v[i]]) {
        t++;
        find = true;
        break;
      }
    if (!find) return false;
  }
  return true;
}
int reverse(std::vector<int> const& v) {
  int n = v.size();
  int ret = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (v[i] > v[j]) ret++;
  return ret;
}
int calc(int x) {
  std::vector<int> v;
  for (int i = 0; i < n; i++) v.push_back(i);
  int max = 0;
  do {
    if (match(v, x)) max = std::max(max, n * (n - 1) / 2 + 1 - reverse(v));
  } while (std::next_permutation(v.begin(), v.end()));
  return max;
}
int main() {
  std::cin >> n;
  prob.resize(n);
  for (int i = 0; i < n; i++) std::cin >> prob[i];
  std::cin >> m;
  dict.resize(m);
  for (int i = 0, x; i < m; i++) {
    std::cin >> x;
    dict[i].resize(x);
    for (int j = 0; j < x; j++) std::cin >> dict[i][j];
  }
  int maxp = 0, pos;
  for (int i = 0; i < m; i++) {
    int p = calc(i);
    if (p > maxp) {
      maxp = p;
      pos = i + 1;
    }
  }
  if (!maxp)
    std::cout << "Brand new problem!\n";
  else
    std::cout << pos << "\n[:" << std::string(maxp, '|') << ":]\n";
}
