#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:32000000")
using namespace std;
const double pi = 3.1415926535897932384626433832795;
template <class T>
inline T Sqr(const T &x) {
  return x * x;
}
template <class T>
inline T Abs(const T &x) {
  return x >= 0 ? x : -x;
}
int n;
map<string, int> words;
int cnt;
char buf[1000];
int m;
int a[500005];
int ne[500005][15];
int dp[1 << 15][15 * 14 / 2 + 1];
int bc[1 << 15];
int get(string s) {
  if (words.find(s) == words.end()) words[s] = cnt++;
  return words[s];
}
int calc() {
  int k;
  scanf("%d", &k);
  m = 0;
  for (int i = 0; i < k; i++) {
    scanf("%s", buf);
    int q = get(buf);
    if (q < n) a[m++] = q;
  }
  for (int i = 0; i < n; i++) ne[m][i] = 100000000;
  for (int i = m - 1; i >= 0; i--)
    for (int j = 0; j < n; j++)
      if (a[i] == j)
        ne[i][j] = i;
      else
        ne[i][j] = ne[i + 1][j];
  int N = 1 << n;
  for (int i = 1; i < N; i++) bc[i] = bc[i / 2] + i % 2;
  int M = n * (n - 1) / 2;
  for (int i = 0; i < N; i++)
    for (int j = 0; j <= M; j++) dp[i][j] = 100000000;
  dp[0][0] = 0;
  for (int mask = 0; mask < N; mask++)
    for (int j = 0; j <= M; j++)
      if (dp[mask][j] != 100000000) {
        for (int i = 0; i < n; i++)
          if ((mask & (1 << i)) == 0) {
            int pos = ne[dp[mask][j]][i] + 1;
            int invs = j + bc[mask & ~((1 << i) - 1)];
            dp[mask | (1 << i)][invs] = min(dp[mask | (1 << i)][invs], pos);
          }
      }
  int min_invs = 100000000;
  for (int i = 0; i <= M; i++)
    if (dp[N - 1][i] < 100000000) {
      min_invs = i;
      break;
    }
  if (min_invs == 100000000) return 0;
  return M - min_invs + 1;
}
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", buf);
    get(buf);
  }
  int m;
  scanf("%d", &m);
  int max_sim = 0;
  int max_sim_idx = -1;
  for (int i = 0; i < m; i++) {
    int sim = calc();
    if (sim > max_sim) {
      max_sim = sim;
      max_sim_idx = i;
    }
  }
  if (max_sim == 0)
    cout << "Brand new problem!";
  else {
    cout << max_sim_idx + 1 << endl;
    cout << "[:";
    for (int i = 0; i < max_sim; i++) cout << "|";
    cout << ":]";
  }
}
int main() {
  solve();
  return 0;
}
