#include <bits/stdc++.h>
using namespace std;
struct nqkfa {
  string str;
  int ind;
} arr[140];
vector<string> tasks[10], lesha1, lesha2;
vector<int> v1, v2;
string tmp;
int n, m, k;
void print(vector<string> some) {
  for (int i = 0; i <= some.size() - 1; i++) cout << some[i] << " ";
  cout << endl;
}
int inv_count() {
  int cnt = 0;
  for (int i = 0; i <= n - 2; i++)
    for (int j = i + 1; j <= n - 1; j++)
      if (v2[i] > v2[j]) cnt++;
  return cnt;
}
int calc(vector<string> vs) {
  int ind1 = 0, ind2 = 0;
  while (ind1 < vs.size() && ind2 < lesha2.size()) {
    if (vs[ind1] == lesha2[ind2]) ind2++;
    ind1++;
  }
  if (ind2 == lesha2.size()) return n * (n - 1) / 2 - inv_count() + 1;
  return -1;
}
void update() {
  for (int i = 0; i <= n - 1; i++) lesha2[i] = arr[v2[i]].str;
}
void init() {
  cin >> n;
  cin.ignore();
  v1.resize(n);
  for (int i = 0; i <= n - 1; i++) v1[i] = i;
  for (int i = 1; i <= n; i++) {
    cin >> tmp;
    lesha1.push_back(tmp);
    arr[i - 1].str = tmp;
  }
  lesha2.resize(n);
  cin >> m;
  cin.ignore();
  for (int i = 1; i <= m; i++) {
    cin >> k;
    cin.ignore();
    for (int j = 1; j <= k; j++) {
      cin >> tmp;
      tasks[i - 1].push_back(tmp);
    }
  }
  int ind_sol = -1, similarity = -1;
  for (int i = 0; i <= m - 1; i++) {
    v2 = v1;
    do {
      for (int i = 0; i <= n - 1; i++) lesha2[i] = lesha1[v2[i]];
      int curr_similarity = calc(tasks[i]);
      if (curr_similarity > similarity) {
        ind_sol = i + 1;
        similarity = curr_similarity;
      }
    } while (next_permutation(v2.begin(), v2.end()));
  }
  if (ind_sol != -1) {
    cout << ind_sol << endl << "[:";
    for (int i = 1; i <= similarity; i++) cout << '|';
    cout << ":]\n";
  } else
    cout << "Brand new problem!\n";
}
int main() {
  init();
  return 0;
}
