#include <bits/stdc++.h>
using namespace std;
int n;
int m;
char s[5][20];
char d[20][20];
int c;
int idx[10];
bool ok() {
  int i = 0, j = 0;
  while (i < n) {
    while (strcmp(d[j], s[idx[i]]) && j < c - 1) j++;
    if (strcmp(d[j], s[idx[i]])) {
      return false;
    } else {
      i++;
    }
  }
  return true;
}
inline int inv() {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += idx[i] > idx[j];
    }
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  int I = -1;
  int max_ans = -1;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &c);
    for (int j = 0; j < c; j++) {
      scanf("%s", d[j]);
    }
    for (int j = 0; j < n; j++) {
      idx[j] = j;
    }
    do {
      if (ok()) {
        int ans = n * (n - 1) / 2 - inv() + 1;
        if (ans > max_ans) {
          max_ans = ans;
          I = i;
        }
      }
    } while (next_permutation(idx, idx + n));
  }
  if (I == -1) {
    puts("Brand new problem!");
  } else {
    printf("%d\n", I + 1);
    printf("[:");
    while (max_ans--) putchar('|');
    printf(":]\n");
  }
  return 0;
}
