#include <bits/stdc++.h>
void Get(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
long long GetS() {
  char S[15];
  scanf("%s", S + 1);
  long long Ans = 0;
  int Len = strlen(S + 1);
  for (int i = 1; i <= Len; i++) {
    Ans = Ans * 27 + S[i] - 'a' + 1;
  }
  return Ans;
}
int N;
long long S[25];
int Search(long long X) {
  for (int i = 1; i <= N; i++)
    if (S[i] == X) return i;
  return 0;
}
void Init() {
  Get(N);
  for (int i = 1; i <= N; i++) S[i] = GetS();
}
int M;
int Str[500005];
int Next[500005][25];
int F[35005][115];
int Cnt[35005];
int Order[35005];
int InvCnt;
int Process() {
  Get(M);
  for (int i = 1; i <= M; i++) {
    Str[i] = Search(GetS());
  }
  for (int j = 1; j <= N; j++) Next[M + 1][j] = M + 1;
  for (int i = M; i >= 1; i--) {
    for (int j = 1; j <= N; j++) Next[i][j] = Next[i + 1][j];
    Next[i][Str[i]] = i;
  }
  for (int k = 0; k < (1 << N); k++)
    for (int i = 0; i <= InvCnt; i++) F[k][i] = M + 1;
  F[0][0] = 0;
  for (int k = 0, i; k < (1 << N); k++) {
    i = Order[k];
    for (int p = 1; p <= N; p++)
      if ((((i) >> (p - 1)) & 1) == 0) {
        int q = (1 << (p)) - 1;
        int New = __builtin_popcount(i & (~q));
        for (int j = 0; j + New <= InvCnt; j++) {
          if (F[i][j] < M + 1) {
            int X = Next[F[i][j] + 1][p];
            if (F[i | (((1) << (p - 1)))][j + New] > X)
              F[i | (((1) << (p - 1)))][j + New] = X;
          }
        }
      }
  }
  for (int i = 0; i <= InvCnt; i++)
    if (F[(1 << N) - 1][i] <= M) return i;
  return 0x2f2f2f2f;
}
bool Cmp(int X, int Y) { return Cnt[X] < Cnt[Y]; }
int Ans;
int Ans2;
void Work() {
  for (int i = 0; i < (1 << N); i++) {
    Order[i] = i;
    Cnt[i] = __builtin_popcount(i);
  }
  InvCnt = (N * (N - 1) >> 1);
  std::sort(Order, Order + (1 << N), Cmp);
  Ans = 0x2f2f2f2f;
  int K;
  Get(K);
  for (int k = 1; k <= K; k++) {
    int Ans0 = Process();
    if (Ans0 < Ans) {
      Ans = Ans0;
      Ans2 = k;
    }
  }
}
void Output() {
  if (Ans == 0x2f2f2f2f)
    puts("Brand new problem!");
  else {
    printf("%d\n", Ans2);
    printf("[:");
    for (int i = 1; i <= InvCnt - Ans + 1; i++) printf("|");
    puts(":]");
  }
}
int main() {
  Init();
  Work();
  Output();
  return 0;
}
