#include <bits/stdc++.h>
using namespace std;
struct node {
  char s[21][25];
  int k;
} v[10];
int main() {
  int n, m, i, j, x, y, f[4];
  cin >> n;
  char a[4][120];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    f[i] = i;
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> v[i].k;
    for (j = 0; j < v[i].k; j++) cin >> v[i].s[j];
  }
  int p = 20, ans = 10000;
  do {
    int sum = 0, i;
    for (i = 0; i < n; i++) {
      for (j = 0; j < i; j++) {
        if (f[j] > f[i]) sum++;
      }
    }
    if (sum > ans) continue;
    for (x = 0; x < m; x++) {
      int k = 0;
      for (y = 0; y < v[x].k && k < n; y++)
        if (strcmp(a[f[k]], v[x].s[y]) == 0) k++;
      if (k >= n) break;
    }
    if (x < m && (sum < ans || sum == ans && p > x)) {
      p = x;
      ans = sum;
    }
  } while (next_permutation(f, f + n));
  if (p == 20)
    cout << "Brand new problem!" << endl;
  else {
    cout << p + 1 << endl;
    cout << "[:";
    int t = n * (n - 1) / 2 + 1 - ans;
    for (i = 0; i < t; i++) cout << "|";
    cout << ":]";
  }
  return 0;
}
