#include <bits/stdc++.h>
using namespace std;
vector<pair<int, string> > problem;
int n, m;
vector<string> archive[16];
bool is_sub(int p) {
  vector<string> pr = archive[p];
  int j = 0, sz = pr.size();
  for (int i = 0; j < problem.size() && i < sz; ++i) {
    if (problem[j].second == pr[i]) ++j;
  }
  return j == problem.size();
}
int invers() {
  int sz = problem.size(), cnt = 0;
  for (int i = 0; i < sz - 1; ++i) {
    for (int j = i + 1; j < sz; ++j) {
      if (problem[i].first > problem[j].first) ++cnt;
    }
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int mini = INT_MAX, idx = -1, k;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    problem.push_back(make_pair(i, s));
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> k;
    for (int j = 0; j < k; ++j) {
      cin >> s;
      archive[i].push_back(s);
    }
  }
  sort(problem.begin(), problem.end());
  do {
    for (int i = 0; i < m; ++i) {
      if (is_sub(i)) {
        int x = invers();
        if (x < mini) {
          idx = i + 1;
          mini = x;
        } else if (x == mini && idx > i + 1) {
          idx = i + 1;
        }
      }
    }
  } while (next_permutation(problem.begin(), problem.end()));
  if (mini == INT_MAX) {
    cout << "Brand new problem!"
         << "\n";
  } else {
    int p = n * (n - 1) / 2 - mini + 1;
    cout << idx << "\n";
    cout << "[:";
    for (int i = 0; i < p; ++i) {
      cout << "|";
    }
    cout << ":]"
         << "\n";
  }
  return 0;
}
