#include <bits/stdc++.h>
using namespace std;
long n, bst;
string w[2000];
long tests, k, cc, gt, bp;
string z[2000];
void generate(vector<long> v) {
  if (v.size() < n) {
    for (int j = 1; j <= k; j++) {
      v.push_back(j);
      generate(v);
      v.pop_back();
    }
    return;
  }
  for (int i = 0; i < v.size(); i++)
    if (z[v[i]] != w[i + 1]) return;
  long ci = 0;
  for (int i = 0; i < v.size(); i++)
    for (int j = i + 1; j < v.size(); j++) {
      if (v[i] < v[j]) ++ci;
    }
  if (ci > bst) {
    bst = ci;
    bp = gt;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  bst = -1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
  }
  cin >> tests;
  for (; tests; --tests) {
    cin >> k;
    ++cc;
    gt = cc;
    for (int j = 1; j <= k; j++) cin >> z[j];
    vector<long> vec;
    generate(vec);
  }
  if (bst < 0)
    cout << "Brand new problem!" << endl;
  else {
    cout << bp << endl;
    cout << "[:|";
    for (int i = 1; i <= bst; i++) cout << "|";
    cout << ":]" << endl;
  }
  cin.get();
  cin.get();
  return 0;
}
