#include <bits/stdc++.h>
using namespace std;
int n, m, k;
string s[30], t[30];
int ans1, ans2;
int p[30];
void dfs(int d, int ind) {
  if (d == n) {
    int r = 0;
    for (int i = 0; i < n; ++i)
      for (int j = i + 1; j < n; ++j)
        if (p[i] > p[j]) ++r;
    if (r < ans1) {
      ans1 = r;
      ans2 = ind;
    }
    return;
  }
  for (int i = 0; i < k; ++i)
    if (s[d] == t[i]) {
      p[d] = i;
      dfs(d + 1, ind);
    }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> s[i];
  cin >> m;
  ans1 = 1000, ans2 = 0;
  for (int i = 0; i < m; ++i) {
    cin >> k;
    for (int j = 0; j < k; ++j) cin >> t[j];
    dfs(0, i + 1);
  }
  if (ans2 == 0)
    cout << "Brand new problem!" << endl;
  else {
    cout << ans2 << endl << "[:";
    for (int i = 0; i < n * (n - 1) / 2 - ans1 + 1; ++i) cout << "|";
    cout << ":]" << endl;
  }
  return 0;
}
