#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p[6] = {0, 1, 2, 3, 4, 5}, ansinv = 1000, inv, ans = 1e9;
string s[100], a[100];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) cin >> a[j];
    do {
      inv = 0;
      for (int g = 0; g < n - 1; g++)
        for (int h = g + 1; h < n; h++)
          if (p[g] > p[h]) inv++;
      if (inv < ansinv) {
        int uk = 0, uk1 = 0;
        while (uk < k && uk1 < n) {
          while (s[p[uk1]] != a[uk] && uk < k) uk++;
          uk1++, uk++;
        }
        if (uk <= k && uk1 == n) ansinv = inv, ans = i;
      }
    } while (next_permutation(p, p + n));
  }
  if (ans != 1e9) {
    cout << ans + 1 << endl;
    cout << "[:";
    for (int i = 0; i < n * (n - 1) / 2 - ansinv + 1; i++) cout << '|';
    cout << ":]";
  } else
    cout << "Brand new problem!";
  cin >> n;
  return 0;
}
