#include <bits/stdc++.h>
using namespace std;
string s1[5];
int p[5];
string s2[25];
string olds[5];
string s3[5];
int n, m, k;
int calc() {
  int res = 0;
  for (int i = (0); i < (n); ++i)
    for (int j = (i + 1); j < (n); ++j)
      if (p[j] < p[i]) res++;
  return res;
}
int check() {
  int i = 0, j = 0;
  while ((i < n) && (j < k)) {
    if (s1[i] == s2[j]) i++;
    j++;
  }
  return (i == n);
}
int main() {
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    cin >> s1[i];
    olds[i] = s1[i];
  }
  cin >> m;
  int res = 0;
  int res1 = -1;
  for (int i = (0); i < (m); ++i) {
    cin >> k;
    for (int j = (0); j < (k); ++j) cin >> s2[j];
    for (int j = (0); j < (n); ++j) p[j] = j;
    do {
      for (int j = (0); j < (n); ++j) s3[j] = olds[p[j]];
      for (int j = (0); j < (n); ++j) s1[j] = s3[j];
      if (check()) {
        int v = calc();
        if ((n * (n - 1) / 2 - v + 1 > res)) {
          res = ((res < n * (n - 1) / 2 - v + 1) ? (n * (n - 1) / 2 - v + 1)
                                                 : (res));
          res1 = i + 1;
        }
      }
    } while (next_permutation(p, p + n));
  }
  if (res1 == -1)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", res1);
    printf("[:");
    for (int j = (0); j < (res); ++j) printf("|");
    printf(":]\n");
  }
  return 0;
}
