#include <bits/stdc++.h>
using namespace std;
int cnt, k, n;
int pos[100];
string a[100], s[100];
int line = 0, inv = 100;
void count(int l) {
  int v = 0;
  for (int i = 1; i < cnt; i++)
    for (int j = i + 1; j <= cnt; j++)
      if (pos[i] > pos[j]) v++;
  if (v < inv) {
    inv = v;
    line = l;
  }
}
void find(int num, int k, int l) {
  for (int i = 1; i <= k; i++)
    if (s[i] == a[num]) {
      pos[num] = i;
      if (num < cnt)
        find(num + 1, k, l);
      else
        count(l);
    }
}
int main() {
  cin >> cnt;
  for (int i = 1; i <= cnt; i++) cin >> a[i];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> k;
    for (int q = 1; q <= cnt; q++) pos[q] = 0;
    for (int j = 1; j <= k; j++) cin >> s[j];
    find(1, k, i);
  }
  if (line != 0) {
    cout << line << endl;
    cout << "[:";
    for (int i = 1; i <= cnt * (cnt - 1) / 2 - inv + 1; i++) cout << "|";
    cout << ":]";
  } else
    cout << "Brand new problem!";
  return 0;
}
