#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  int ans;
  string s;
  vector<string> problem;
  vector<string> archive[20];
  cin >> n;
  for (typeof(0) i = (0); i < (n); ++i) {
    cin >> s;
    problem.push_back(s);
  }
  cin >> m;
  for (typeof(0) i = (0); i < (m); ++i) {
    cin >> k;
    for (typeof(0) j = (0); j < (k); ++j) {
      cin >> s;
      archive[i].push_back(s);
    }
  }
  int inv, mi = 10000;
  ans = 100;
  int a[4] = {0, 1, 2, 3};
  do {
    for (typeof(0) i = (0); i < (m); ++i) {
      bool found = true;
      int sz = ((int)(archive[i]).size()), start = 0;
      for (typeof(0) j = (0); j < (n); ++j) {
        int s;
        for (s = start; s < sz; ++s) {
          if (problem[a[j]] == archive[i][s]) {
            start = s + 1;
            break;
          }
        }
        if (s == sz) {
          found = false;
          break;
        }
      }
      if (!found) continue;
      inv = 0;
      for (typeof(0) j = (0); j < (n); ++j)
        for (typeof(j + 1) j2 = (j + 1); j2 < (n); ++j2)
          if (a[j] > a[j2]) ++inv;
      if (inv <= mi) {
        mi = inv;
        ans = min(ans, i + 1);
      }
    }
  } while (next_permutation(a, a + n));
  if (mi == 10000) {
    puts("Brand new problem!");
    return 0;
  }
  int rep = n * (n - 1) / 2 - mi + 1;
  printf("%d\n", ans);
  printf("[:");
  for (typeof(0) i = (0); i < (rep); ++i) printf("|");
  printf(":]\n");
  return 0;
}
