#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long INF_LL = 1000000000000000000LL;
const double pi = 2 * acos(0.0);
template <class T>
void smin(T& a, T b) {
  if (a > b) a = b;
}
template <class T>
void smax(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
void outp(const vector<T>& v) {
  for (int i(0), _b(int((v).size())); i < _b; ++i)
    cout << v[i] << (i + 1 == int((v).size()) ? '\n' : ' ');
}
template <class T>
void outp(T* v, int n) {
  for (int i(0), _b(n); i < _b; ++i) cout << *v++ << (i + 1 == n ? '\n' : ' ');
}
const int h = 500005, N = 15;
int n, pm, m, k;
char s[N];
vector<int> a;
int r[h][N];
int d[1 << N][N * (N - 1) / 2 + 1];
const int V = 15 * 10 * 2;
int t[V][26], p[V], nv = 1;
int solve() {
  k = int((a).size());
  if (k == 0) return -1;
  for (int i(0), _b(n); i < _b; ++i) r[k][i] = k;
  for (int j(k - 1), _b(0); j >= _b; --j) {
    for (int i(0), _b(n); i < _b; ++i) r[j][i] = r[j + 1][i];
    r[j][a[j]] = j;
  }
  for (int u(0), _b(1 << n); u < _b; ++u)
    for (int c(0), _b(pm + 1); c < _b; ++c) d[u][c] = k;
  d[0][0] = 0;
  for (int u(0), _b((1 << n) - 1); u < _b; ++u)
    for (int c(0), _b(pm + 1); c < _b; ++c)
      if (d[u][c] != k) {
        int l = 0;
        for (int i(0), _b(n); i < _b; ++i)
          if (u & 1 << i) ++l;
        for (int i(0), _b(n); i < _b; ++i)
          if (~u & 1 << i)
            smin(d[u | 1 << i][c + l], r[d[u][c]][i]);
          else
            --l;
      }
  for (int c(0), _b(pm + 1); c < _b; ++c)
    if (d[(1 << n) - 1][c] != k) return pm - c + 1;
  return -1;
}
int main() {
  scanf("%d", &n);
  pm = n * (n - 1) / 2;
  for (int i(0), _b(n); i < _b; ++i) {
    scanf("%s", s);
    int v = 0;
    for (int c(0), _b(strlen(s)); c < _b; ++c) {
      int e = s[c] - 'a';
      if (!t[v][e]) t[v][e] = nv++;
      v = t[v][e];
    }
    p[v] = i + 1;
  }
  int pr, ans = 0;
  scanf("%d", &m);
  for (int im(0), _b(m); im < _b; ++im) {
    scanf("%d", &k);
    a.clear();
    for (int j(0), _b(k); j < _b; ++j) {
      scanf("%s", s);
      int v = 0;
      for (int c(0), _b(strlen(s)); c < _b; ++c) {
        int e = s[c] - 'a';
        v = t[v][e];
        if (!v) break;
      }
      if (p[v]) a.push_back(p[v] - 1);
    }
    int cur = solve();
    if (cur > ans) ans = cur, pr = im + 1;
  }
  if (!ans)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", pr);
    printf("[:");
    for (int i(0), _b(ans); i < _b; ++i) printf("|");
    printf(":]\n");
  }
}
