#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[4][12];
char t[12][25][12];
int num[12];
int main() {
  int i, j;
  int ans = 0, p = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%s", s[i]);
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d", &num[i]);
    for (j = 0; j < num[i]; j++) scanf("%s", t[i][j]);
  }
  int mark[4];
  int rec[25];
  for (int k = 0; k < m; k++) {
    memset(mark, 0, sizeof(mark));
    memset(rec, -1, sizeof(rec));
    for (i = 0; i < 4; i++) {
      for (j = 0; j < num[k]; j++) {
        if (strcmp(s[i], t[k][j]) == 0) {
          mark[i] = 1;
          rec[j] = i;
        }
      }
    }
    int sum = 0;
    for (i = 0; i < n; i++) sum += mark[i];
    if (sum < n) continue;
    int id[4] = {0, 1, 2, 3};
    do {
      j = 0;
      for (i = 0; i < num[k]; i++) {
        if (rec[i] == id[j]) {
          j++;
          if (j == n) break;
        }
      }
      int x = 0;
      for (i = 0; i < n - 1; i++)
        for (int tt = i + 1; tt < n; tt++)
          if (id[i] > id[tt]) x++;
      if (j == n && n * (n - 1) / 2 - x + 1 > p) {
        ans = k + 1;
        p = n * (n - 1) / 2 - x + 1;
      }
    } while (next_permutation(id, id + n));
  }
  if (ans == 0)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", ans);
    printf("[:");
    for (i = 0; i < p; i++) printf("|");
    printf(":]\n");
  }
  return 0;
}
