#include <bits/stdc++.h>
using namespace std;
struct permutation {
  vector<int> perm;
  int noInversions;
  permutation() {}
  permutation(vector<int> a, int b) {
    perm = a;
    noInversions = b;
  }
};
bool substring(vector<int> perm, vector<string> a, vector<string> b) {
  int currentB = 0;
  for (int i = 0; i < perm.size(); i++) {
    while (true) {
      if (currentB >= b.size()) return false;
      if (a[perm[i]] == b[currentB]) {
        currentB++;
        break;
      }
      currentB++;
    }
  }
  return true;
}
int main(int argc, char *argv[]) {
  vector<permutation> one;
  vector<int> temp;
  temp.push_back(0);
  one.push_back(permutation(temp, 0));
  vector<permutation> two;
  temp.clear();
  temp.push_back(0);
  temp.push_back(1);
  two.push_back(permutation(temp, 0));
  temp.clear();
  temp.push_back(1);
  temp.push_back(0);
  two.push_back(permutation(temp, 1));
  vector<permutation> three;
  temp.clear();
  temp.push_back(0);
  temp.push_back(1);
  temp.push_back(2);
  three.push_back(permutation(temp, 0));
  temp.clear();
  temp.push_back(0);
  temp.push_back(2);
  temp.push_back(1);
  three.push_back(permutation(temp, 1));
  temp.clear();
  temp.push_back(1);
  temp.push_back(0);
  temp.push_back(2);
  three.push_back(permutation(temp, 1));
  temp.clear();
  temp.push_back(1);
  temp.push_back(2);
  temp.push_back(0);
  three.push_back(permutation(temp, 2));
  temp.clear();
  temp.push_back(2);
  temp.push_back(1);
  temp.push_back(0);
  three.push_back(permutation(temp, 3));
  temp.clear();
  temp.push_back(2);
  temp.push_back(0);
  temp.push_back(1);
  three.push_back(permutation(temp, 2));
  vector<permutation> four;
  temp.clear();
  temp.push_back(0);
  temp.push_back(1);
  temp.push_back(2);
  temp.push_back(3);
  four.push_back(permutation(temp, 0));
  temp.clear();
  temp.push_back(0);
  temp.push_back(1);
  temp.push_back(3);
  temp.push_back(2);
  four.push_back(permutation(temp, 1));
  temp.clear();
  temp.push_back(0);
  temp.push_back(2);
  temp.push_back(1);
  temp.push_back(3);
  four.push_back(permutation(temp, 1));
  temp.clear();
  temp.push_back(0);
  temp.push_back(2);
  temp.push_back(3);
  temp.push_back(1);
  four.push_back(permutation(temp, 2));
  temp.clear();
  temp.push_back(0);
  temp.push_back(3);
  temp.push_back(2);
  temp.push_back(1);
  four.push_back(permutation(temp, 3));
  temp.clear();
  temp.push_back(0);
  temp.push_back(3);
  temp.push_back(1);
  temp.push_back(2);
  four.push_back(permutation(temp, 2));
  temp.clear();
  temp.push_back(1);
  temp.push_back(0);
  temp.push_back(2);
  temp.push_back(3);
  four.push_back(permutation(temp, 1));
  temp.clear();
  temp.push_back(1);
  temp.push_back(0);
  temp.push_back(3);
  temp.push_back(2);
  four.push_back(permutation(temp, 2));
  temp.clear();
  temp.push_back(1);
  temp.push_back(2);
  temp.push_back(3);
  temp.push_back(0);
  four.push_back(permutation(temp, 3));
  temp.clear();
  temp.push_back(1);
  temp.push_back(2);
  temp.push_back(0);
  temp.push_back(3);
  four.push_back(permutation(temp, 2));
  temp.clear();
  temp.push_back(1);
  temp.push_back(3);
  temp.push_back(0);
  temp.push_back(2);
  four.push_back(permutation(temp, 3));
  temp.clear();
  temp.push_back(1);
  temp.push_back(3);
  temp.push_back(2);
  temp.push_back(0);
  four.push_back(permutation(temp, 4));
  temp.clear();
  temp.push_back(2);
  temp.push_back(0);
  temp.push_back(1);
  temp.push_back(3);
  four.push_back(permutation(temp, 2));
  temp.clear();
  temp.push_back(2);
  temp.push_back(0);
  temp.push_back(3);
  temp.push_back(1);
  four.push_back(permutation(temp, 3));
  temp.clear();
  temp.push_back(2);
  temp.push_back(1);
  temp.push_back(3);
  temp.push_back(0);
  four.push_back(permutation(temp, 4));
  temp.clear();
  temp.push_back(2);
  temp.push_back(1);
  temp.push_back(0);
  temp.push_back(3);
  four.push_back(permutation(temp, 3));
  temp.clear();
  temp.push_back(2);
  temp.push_back(3);
  temp.push_back(0);
  temp.push_back(1);
  four.push_back(permutation(temp, 4));
  temp.clear();
  temp.push_back(2);
  temp.push_back(3);
  temp.push_back(1);
  temp.push_back(0);
  four.push_back(permutation(temp, 5));
  temp.clear();
  temp.push_back(3);
  temp.push_back(0);
  temp.push_back(1);
  temp.push_back(2);
  four.push_back(permutation(temp, 3));
  temp.clear();
  temp.push_back(3);
  temp.push_back(0);
  temp.push_back(2);
  temp.push_back(1);
  four.push_back(permutation(temp, 4));
  temp.clear();
  temp.push_back(3);
  temp.push_back(1);
  temp.push_back(2);
  temp.push_back(0);
  four.push_back(permutation(temp, 5));
  temp.clear();
  temp.push_back(3);
  temp.push_back(1);
  temp.push_back(0);
  temp.push_back(2);
  four.push_back(permutation(temp, 4));
  temp.clear();
  temp.push_back(3);
  temp.push_back(2);
  temp.push_back(0);
  temp.push_back(1);
  four.push_back(permutation(temp, 5));
  temp.clear();
  temp.push_back(3);
  temp.push_back(2);
  temp.push_back(1);
  temp.push_back(0);
  four.push_back(permutation(temp, 6));
  int n;
  cin >> n;
  vector<string> input(n);
  for (int i = 0; i < n; i++) {
    cin >> input[i];
  }
  int m, tempa;
  cin >> m;
  vector<vector<string> > problemset;
  for (int i = 0; i < m; i++) {
    cin >> tempa;
    vector<string> problem(tempa);
    for (int j = 0; j < tempa; j++) {
      cin >> problem[j];
    }
    problemset.push_back(problem);
  }
  vector<permutation> used;
  if (n == 1)
    used = one;
  else if (n == 2)
    used = two;
  else if (n == 3)
    used = three;
  else
    used = four;
  int inversions = 7, index = -1;
  for (int whole = 0; whole < problemset.size(); whole++) {
    for (int i = 0; i < used.size(); i++) {
      if (substring(used[i].perm, input, problemset[whole])) {
        if (inversions > used[i].noInversions) {
          inversions = used[i].noInversions;
          index = whole + 1;
        }
      }
    }
  }
  if (index == -1)
    std::cout << "Brand new problem!" << std::endl;
  else {
    std::cout << index << std::endl;
    std::cout << "[:";
    for (int i = 0; i < (n * (n - 1)) / 2 + 1 - inversions; i++) {
      std::cout << "|";
    }
    std::cout << ":]" << std::endl;
  }
  return 0;
}
