#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
char lesha[maxn][maxn];
char pep[15][maxn][15];
int pepl[15];
int n, m;
int pos[6][15];
int lu[6];
void dfs(int &x, int s, int e) {
  int i, j, k;
  if (s == e) {
    k = 0;
    for (i = 0; i < e; i++)
      for (j = i + 1; j < e; j++)
        if (lu[j] < lu[i]) k++;
    if (k < x) x = k;
    return;
  }
  for (i = 1; i <= pos[s][0]; i++) {
    lu[s] = pos[s][i];
    dfs(x, s + 1, e);
  }
}
int main() {
  int archive, p, x;
  int i, j, k, tmp, l, lk;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%s", lesha[i]);
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &pepl[i]);
    for (j = 0; j < pepl[i]; j++) scanf("%s", pep[i][j]);
  }
  p = -1;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k < pepl[i]; k++)
        if (strcmp(pep[i][k], lesha[j]) == 0) break;
      if (k < pepl[i])
        continue;
      else
        break;
    }
    if (j < n) continue;
    for (j = 0; j < n; j++) {
      pos[j][0] = 0;
      for (k = 0; k < pepl[i]; k++)
        if (strcmp(pep[i][k], lesha[j]) == 0) {
          pos[j][0]++;
          pos[j][pos[j][0]] = k;
        }
    }
    x = n * n;
    dfs(x, 0, n);
    tmp = n * (n - 1) / 2 - x + 1;
    if (tmp > p) {
      p = tmp;
      archive = i + 1;
    }
  }
  if (p == -1)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", archive);
    printf("[:");
    for (i = 0; i < p; i++) printf("|");
    printf(":]\n");
  }
  return 0;
}
