#include <bits/stdc++.h>
using namespace std;
std::vector<string> topcoder;
std::vector<string> permutation[50];
int in[50];
int ct = 0;
std::vector<string> v;
int A(string x) {
  for (int i = 0; i < v.size(); i++)
    if (x == v[i]) return i;
}
int n, sol = 0, idx = 0;
int isInTopcoder(int idx) {
  int j = 0;
  for (int i = 0; i < topcoder.size() and j < n; i++)
    if (topcoder[i] == permutation[idx][j]) j++;
  if (j == n) return 1;
  return 0;
}
void permute(int s, int e) {
  if (s == e) {
    for (int j = 0; j < n; j++) permutation[ct].push_back(v[j]);
    ct++;
    return;
  }
  for (int i = s; i <= e; i++) {
    swap(v[s], v[i]);
    permute(s + 1, e);
    swap(v[s], v[i]);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    v.push_back(temp);
  }
  permute(0, n - 1);
  for (int i = 0; i < ct; i++) {
    for (int j = 0; j < n; j++)
      for (int k = 0; k < j; k++)
        in[i] += A(permutation[i][j]) < A(permutation[i][k]);
  }
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    topcoder.clear();
    for (int j = 0; j < k; j++) {
      string temp;
      cin >> temp;
      topcoder.push_back(temp);
    }
    for (int j = 0; j < ct; j++)
      if (isInTopcoder(j)) {
        int temp = 0;
        temp = ((n * (n - 1)) >> 1) + (-in[j] + 1);
        if (temp > sol) sol = temp, idx = i;
      }
  }
  if (sol == 0) {
    cout << "Brand new problem!" << endl;
  } else {
    cout << idx << endl;
    cout << "[:";
    for (int j = 0; j < sol; j++) cout << "|";
    cout << ":]" << endl;
  }
  return 0;
}
