#include <bits/stdc++.h>
using namespace std;
vector<string> lesha, lesha1;
map<string, int> ma;
vector<vector<string> > tc;
int n, m, k;
int inv(vector<string> a) {
  int r = 0;
  for (int i = 0; i < a.size() - 1; i++) {
    for (int j = i + 1; j < a.size(); j++) {
      if (ma[a[i]] > ma[a[j]]) {
        r++;
      }
    }
  }
  return r;
}
int sim(vector<string> a, vector<string> b) {
  int i = 0, j = 0;
  int x = inv(a);
  while ((j < b.size()) && (i < a.size())) {
    if (a[i] == b[j]) {
      i++;
      j++;
    } else {
      j++;
    }
  }
  if (i == a.size()) {
    return ((n * (n - 1)) / 2) - x + 1;
  } else {
    return 0;
  }
}
int main() {
  cin >> n;
  lesha.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> lesha[i];
    ma[lesha[i]] = i;
  }
  lesha1 = lesha;
  cin >> m;
  tc.resize(m);
  for (int i = 0; i < m; i++) {
    cin >> k;
    tc[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> tc[i][j];
    }
  }
  int rez = 0, d1 = 0;
  for (int i = 0; i < 240; i++) {
    for (int j = 0; j < tc.size(); j++) {
      if (sim(lesha1, tc[j]) > rez) {
        rez = sim(lesha1, tc[j]);
        d1 = j;
      } else {
        if (sim(lesha1, tc[j]) == rez) {
          d1 = min(d1, j);
        }
      }
    }
    next_permutation(lesha1.begin(), lesha1.end());
  }
  if (rez == 0) {
    cout << "Brand new problem!\n";
  } else {
    cout << d1 + 1 << endl;
    cout << "[:";
    for (int i = 0; i < rez; i++) {
      cout << "|";
    }
    cout << ":]\n";
  }
  return 0;
}
