#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  vector<vector<string>> b(m);
  bool new_problem = 1;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    b[i].resize(k);
    for (int j = 0; j < k; j++) cin >> b[i][j];
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      for (int p = 0; p < k; p++) {
        if (a[j] == b[i][p]) {
          cnt++;
          break;
        }
      }
    }
    new_problem &= cnt != n;
  }
  if (new_problem) {
    cout << "Brand new problem!\n";
    return 0;
  }
  vector<int> p(n);
  iota(p.begin(), p.end(), 0);
  const int INF = 1e9;
  pair<int, int> best = {INF, INF};
  do {
    int cost = 0;
    for (int i = 1; i < n; i++) {
      for (int j = i - 1; j >= 0; j--) cost += p[i] < p[j];
    }
    int take = -1;
    for (int i = 0; i < m; i++) {
      int ptr = 0;
      for (int j = 0; j < (int)b[i].size(); j++) {
        if (a[p[ptr]] == b[i][j]) ptr++;
        if (ptr == n) {
          break;
        }
      }
      if (ptr == n) {
        take = i;
        break;
      }
    }
    if (take != -1) {
      if (cost < best.first || (cost == best.first && take < best.second))
        best = {cost, take};
    }
  } while (next_permutation(p.begin(), p.end()));
  int x = (n * (n - 1) / 2 - best.first + 1);
  cout << best.second + 1 << '\n';
  cout << "[:";
  while (x) {
    cout << '|';
    x--;
  }
  cout << ":]\n";
}
