#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> a, aa;
vector<int> v;
int u[2000000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  for (int i = 0; i < 1000000; i++) u[i] = i;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i], v.push_back(i + 1);
  aa = a;
  int fact = 1;
  for (int i = 2; i <= n; i++) fact *= i;
  int m;
  cin >> m;
  int ans = 0;
  int anss = -1;
  for (int i = 0; i < m; i++) {
    vector<string> b;
    int k;
    cin >> k;
    b.resize(k);
    for (int j = 0; j < k; j++) cin >> b[j];
    for (int l = 0; l < fact; l++) {
      int p = 0;
      for (int j = 0; j < k; j++)
        if (b[j] == a[p]) {
          p++;
          if (p == n) break;
        }
      if (p == n) {
        int X = 0;
        for (int j = 0; j < n; j++)
          for (int p = j + 1; p < n; p++)
            if (v[j] > v[p]) X++;
        int tmp = n * (n - 1) / 2 - X + 1;
        if (ans < tmp) ans = tmp, anss = i + 1;
      }
      next_permutation(v.begin(), v.end());
      for (int j = 0; j < n; j++) a[j] = aa[v[j] - 1];
    }
  }
  if (ans == 0) {
    next_permutation(a.begin(), a.end());
    cout << "Brand new problem!" << endl;
  } else {
    cout << anss << endl;
    cout << "[:";
    for (int i = 0; i < ans; i++) cout << "|";
    cout << ":]";
  }
  return 0;
}
