#include <bits/stdc++.h>
using namespace std;
int n, m, k;
map<string, int> dict;
int num[99999], f[99999];
void init() {
  ios::sync_with_stdio(false);
  cin >> n;
  string s;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    dict[s] = i;
  }
  num[0] = 0;
  for (int i = 1; i <= ((1 << (n - 1 + 1)) - 1); ++i)
    num[i] = num[i - (i & -i)] + 1;
}
int ans(INT_MAX), pos;
void work() {
  cin >> m;
  for (int z = 0; z < m; ++z) {
    cin >> k;
    fill(f, f + ((1 << (n - 1 + 1)) - 1) + 1, INT_MAX);
    f[0] = 0;
    string s;
    int p = 0, x;
    for (int y = 0; y < k; ++y) {
      cin >> s;
      if (dict.find(s) == dict.end()) continue;
      x = dict[s];
      if ((p & (1 << x)) != 0) continue;
      p = (p & ((1 << (x + 1)) - 1)) | (1 << x);
      for (int i = 0; i <= ((1 << (n - 1 + 1)) - 1); ++i) {
        if ((i & (1 << x)) != 0 || f[i] == INT_MAX) continue;
        if (f[i] + num[i & ~((1 << (x + 1)) - 1)] < f[i | (1 << x)])
          f[i | (1 << x)] = f[i] + num[i & ~((1 << (x + 1)) - 1)];
      }
    }
    if (f[((1 << (n - 1 + 1)) - 1)] < ans)
      ans = f[((1 << (n - 1 + 1)) - 1)], pos = z + 1;
  }
  if (ans == INT_MAX)
    cout << "Brand new problem!" << endl;
  else {
    cout << pos << endl;
    cout << "[:";
    for (int i = 1; i <= (n * (n - 1)) / 2 - ans + 1; ++i) cout << '|';
    cout << ":]" << endl;
  }
}
int main() {
  init();
  work();
  return 0;
}
