#include <bits/stdc++.h>
char s1[5][15], s2[25][15];
bool v[5], vis[25], mark[25];
struct PP {
  int id;
} p[15], st[15];
int sol, min = 1000000000;
int inv(int n, PP *ss) {
  int i, j, sum = 0;
  for (i = 1; i <= n; i++) {
    for (j = i - 1; j >= 1; j--) {
      if (ss[j].id > ss[i].id && mark[j] && mark[i]) sum++;
    }
  }
  return sum;
}
void dfs(int step, int n, int k) {
  int i;
  if (step > n) {
    int tmp = inv(k, st);
    if (tmp < sol) sol = tmp;
  }
  for (i = 1; i <= k; i++) {
    if (!mark[i] && strcmp(s1[step], s2[i]) == 0) {
      mark[i] = 1;
      st[i].id = step;
      dfs(step + 1, n, k);
      mark[i] = 0;
    }
  }
}
int main() {
  int i, j, k;
  int n, m, ans;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%s", s1[i]);
  scanf("%d", &m);
  bool OK = 0;
  int count, t, ca = 0;
  min = 1000000000;
  while (m--) {
    ca++;
    memset(v, 0, sizeof(v));
    memset(vis, 0, sizeof(vis));
    scanf("%d", &k);
    count = 0;
    for (i = 1; i <= k; i++) scanf("%s", s2[i]);
    for (i = 1; i <= n; i++) {
      int flag = 0;
      for (j = 1; j <= k; j++) {
        if (strcmp(s1[i], s2[j]) == 0) {
          flag = 1;
          break;
        }
      }
      count += flag;
    }
    if (count < n) continue;
    OK = 1;
    bool f = 0;
    p[0].id = 1;
    sol = 1000000;
    dfs(1, n, k);
    if (sol < min) {
      min = sol;
      t = ca;
    }
  }
  if (!OK)
    puts("Brand new problem!");
  else {
    printf("%d\n", t);
    ans = n * (n - 1) / 2 - min + 1;
    printf("[:");
    for (i = 0; i < ans; i++) printf("|");
    printf(":]\n");
  }
  return 0;
}
