#include <bits/stdc++.h>
using namespace std;
int n;
int isol;
int sol = 0;
vector<string> v;
int posicion[1 << 15][500];
int posiciones[1000000][15];
void prueba(vector<string> &w, int indice) {
  {
    set<string> s;
    for (int i = 0; i < int(w.size()); i++) s.insert(w[i]);
    for (int i = 0; i < int(v.size()); i++)
      if (s.count(v[i]) == 0) return;
  }
  {
    map<string, int> codigo;
    for (int i = 0; i < int(v.size()); i++) codigo[v[i]] = i;
    for (int j = 0; j < int(v.size()); j++)
      posiciones[int(w.size())][j] = int(w.size());
    for (int i = int(w.size()) - 1; i >= 0; i--) {
      for (int j = 0; j < int(v.size()); j++)
        posiciones[i][j] = posiciones[i + 1][j];
      if (codigo.count(w[i])) posiciones[i][codigo[w[i]]] = i;
    }
  }
  int limitcoste = n * (n - 1) / 2 + 1;
  for (int coste = 0; coste < limitcoste; coste++) posicion[0][coste] = 0;
  for (int c = 1; c < (1 << n); c++) {
    for (int coste = 0; coste < limitcoste; coste++)
      posicion[c][coste] = int(w.size());
    for (int b = 0; b < n; b++) {
      if (c & (1 << b)) {
        int anyadecoste = 0;
        for (int bb = b + 1; bb < n; bb++)
          if (c & (1 << bb)) anyadecoste++;
        int cc = c ^ (1 << b);
        for (int coste = anyadecoste; coste < limitcoste; coste++) {
          int posant = posicion[cc][coste - anyadecoste];
          posicion[c][coste] = min(posicion[c][coste], posiciones[posant][b]);
        }
      }
    }
    for (int coste = 1; coste < limitcoste; coste++)
      posicion[c][coste] = min(posicion[c][coste], posicion[c][coste - 1]);
  }
  for (int coste = 0; coste < limitcoste; coste++) {
    if (posicion[(1 << n) - 1][coste] < int(w.size())) {
      int solact = n * (n - 1) / 2 - coste + 1;
      if (solact > sol) {
        sol = solact;
        isol = indice;
      }
      return;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  v = vector<string>(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int m;
  cin >> m;
  for (int cas = 0; cas < m; cas++) {
    int k;
    cin >> k;
    vector<string> w(k);
    for (int i = 0; i < k; i++) cin >> w[i];
    prueba(w, cas + 1);
  }
  if (sol == 0)
    cout << "Brand new problem!" << endl;
  else {
    cout << isol << endl;
    cout << "[:" << string(sol, '|') << ":]" << endl;
  }
}
