#include <bits/stdc++.h>
using namespace std;
map<string, int> MP;
vector<int> v, vv[25 + 2];
vector<pair<int, int> > vp;
int tot, n, m, Sz[25 + 2], p[22];
string s;
bool go(int id) {
  int i, j;
  for (i = 0, j = 0; i < Sz[id] && j < n; i++) {
    if (vv[id][i] == v[j]) j++;
  }
  return (j == n);
}
int main() {
  scanf("%d", &n);
  int i, j, k = 0;
  for (i = 1; i <= n; i++) {
    cin >> s;
    p[i - 1] = i - 1;
    if (MP.find(s) == MP.end()) {
      MP[s] = ++k;
    }
    int x = MP[s];
    vv[0].push_back(x);
  }
  scanf("%d", &m);
  tot = (n * (n - 1)) / 2 + 1;
  for (i = 1; i <= m; i++) {
    scanf("%d", &Sz[i]);
    for (j = 1; j <= Sz[i]; j++) {
      cin >> s;
      if (MP.find(s) == MP.end()) {
        MP[s] = ++k;
      }
      int x = MP[s];
      vv[i].push_back(x);
    }
  }
  do {
    v.clear();
    int inv = 0;
    for (i = 0; i < n; i++) {
      v.push_back(vv[0][p[i]]);
      for (j = i + 1; j < n; j++) {
        if (p[j] < p[i]) inv++;
      }
    }
    for (i = 1; i <= m; i++) {
      if (go(i)) {
        vp.push_back(make_pair(inv, i));
        break;
      }
    }
  } while (next_permutation(p, p + n));
  sort(vp.begin(), vp.end());
  if (!(int)(vp.size()))
    printf("Brand new problem!\n");
  else {
    printf("%d\n", vp[0].second);
    printf("[:");
    tot -= vp[0].first;
    for (i = 0; i < tot; i++) {
      printf("|");
    }
    printf(":]\n");
  }
  return 0;
}
