#include <bits/stdc++.h>
using namespace std;
const int oo = 1000000000;
char s[15][15];
char str[500010][15];
int dp[1 << 15][110];
int n, m;
int ans = oo, ansx;
vector<int> v[1 << 15], vv[1 << 15];
int f[20][500010];
void init() {
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) continue;
      v[i].push_back(j);
      int cost = 0;
      for (int k = j + 1; k < n; k++)
        if (i & (1 << k)) cost++;
      vv[i].push_back(cost);
    }
  }
}
map<string, int> ma;
set<int> st[25];
void solve(int id) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= m + 1; j++) f[i][j] = oo;
    for (int j = 0; j < m; j++)
      if (!strcmp(s[i], str[j])) f[i][j] = j;
    for (int j = m; j >= 0; j--) f[i][j] = min(f[i][j], f[i][j + 1]);
  }
  int maxn = n * (n - 1) / 2;
  maxn = min(maxn, ans);
  for (int i = 0; i < (1 << n); i++)
    for (int j = 0; j <= maxn; j++) dp[i][j] = oo;
  dp[0][0] = -1;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j <= maxn; j++) {
      if (dp[i][j] >= m - 1) continue;
      for (int k = 0; k < v[i].size(); k++) {
        dp[i | (1 << v[i][k])][j + vv[i][k]] =
            min(dp[i | (1 << v[i][k])][j + vv[i][k]], f[v[i][k]][dp[i][j] + 1]);
      }
    }
  }
  for (int j = 0; j <= maxn; j++)
    if (dp[(1 << n) - 1][j] <= m - 1 && ans > j) {
      ans = j;
      ansx = id;
    }
}
int main() {
  int r;
  scanf("%d", &n);
  init();
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  scanf("%d", &r);
  for (int k = 1; k <= r; k++) {
    scanf("%d", &m);
    for (int i = 0; i < m; i++) scanf("%s", str[i]);
    solve(k);
  }
  if (ans == oo)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", ansx);
    printf("[:");
    ans = n * (n - 1) / 2 - ans + 1;
    while (ans--) printf("|");
    printf(":]\n");
  }
  return 0;
}
