#include <bits/stdc++.h>
using namespace std;
int Np, i, j, k, last;
int Na, Nw[16], ouidx = -1, oup = -1, ousc;
int arr[16];
char p[16][16];
char a[16][16][16];
bool mark[16];
void swap(int *a, int *b) {
  int c = *a;
  *a = *b;
  *b = c;
}
void permut(int idx, int arc) {
  if (idx < Np) {
    int i;
    for (i = 0; i < Np; ++i)
      if (!mark[i]) {
        mark[i] = true;
        arr[idx] = i;
        permut(idx + 1, arc);
        mark[i] = false;
      }
  } else {
    int last = 0, i, arr2[16];
    ;
    for (i = 0; i < Nw[arc]; ++i) {
      if (strcmp(a[arc][i], p[arr[last]]) == 0) {
        arr2[last] = arr[last];
        last += 1;
      }
      if (last >= Np) break;
    }
    if (last >= Np) {
      int j, sc = 0, ns, temp;
      for (i = 0; i < Np - 1; ++i) {
        ns = i;
        for (j = i + 1; j < Np; ++j)
          if (arr2[ns] > arr2[j]) ns = j;
        for (j = ns; j > i; --j) {
          swap(&arr2[j], &arr2[j - 1]);
          sc += 1;
        }
      }
      temp = (Np * (Np - 1) / 2) - sc + 1;
      if (temp > oup) {
        oup = temp;
        ousc = sc;
        ouidx = arc;
      }
    }
  }
}
int main() {
  scanf("%d", &Np);
  for (i = 0; i < Np; ++i) scanf("%s", p[i]);
  scanf("%d", &Na);
  for (i = 0; i < Na; ++i) {
    scanf("%d", &Nw[i]);
    for (j = 0; j < Nw[i]; ++j) scanf("%s", a[i][j]);
    if (Np > Nw[i]) continue;
    permut(0, i);
  }
  if (ouidx > -1) {
    printf("%d\n", ouidx + 1);
    printf("[:");
    for (i = 0; i < oup; ++i) printf("|");
    printf(":]\n");
    return 0;
  }
  printf("Brand new problem!\n");
  return 0;
}
