#include <bits/stdc++.h>
using namespace std;
int p[4] = {0, 1, 2, 3};
vector<string> f, g, h;
int n, m;
bool judge() {
  int i, j;
  i = j = 0;
  while (i < n && j < m) {
    if (g[i] == h[j]) i++;
    j++;
  }
  if (i == n)
    return true;
  else
    return false;
}
int main() {
  scanf("%d", &n);
  f.clear();
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    f.push_back(s);
  }
  int ans1 = 0;
  int ans2;
  int cas;
  scanf("%d", &cas);
  for (int i = 1; i <= cas; i++) {
    scanf("%d", &m);
    h.clear();
    for (int j = 0; j < m; j++) {
      string s;
      cin >> s;
      h.push_back(s);
    }
    do {
      g.clear();
      for (int j = 0; j < n; j++) g.push_back(f[p[j]]);
      if (judge()) {
        if (ans1 == 0) {
          ans1 = i;
          ans2 = 0;
          for (int j = 0; j < n; j++)
            for (int k = j + 1; k < n; k++) {
              if (p[j] > p[k]) ans2++;
            }
        } else {
          int tmp = 0;
          for (int j = 0; j < n; j++)
            for (int k = j + 1; k < n; k++) {
              if (p[j] > p[k]) tmp++;
            }
          if (tmp < ans2) {
            ans1 = i;
            ans2 = tmp;
          }
        }
      }
    } while (next_permutation(p, p + n));
  }
  if (ans1 == 0)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", ans1);
    printf("[:");
    ans2 = (n * (n - 1) / 2) - ans2 + 1;
    while (ans2--) printf("|");
    printf(":]\n");
  }
  return 0;
}
