#include <bits/stdc++.h>
using namespace std;
int n;
int res;
int a[15][555555], la[15];
int d[(1 << 15) + 3][111];
map<string, int> Map;
void update(int& x, int y) {
  if (x == -1 || x > y) x = y;
}
int main() {
  char s[22];
  string S;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    Map[s] = i;
  }
  int u = n * (n - 1) / 2;
  int _, t, w, res = 123456, id;
  scanf("%d", &_);
  for (t = 1; t <= _; t++) {
    int l = 0;
    memset(la, 0, sizeof(la));
    for (scanf("%d", &w); w--;) {
      scanf("%s", s);
      S = s;
      if (Map.count(s)) {
        int x = Map[s];
        a[x][la[x]++] = l++;
      }
    }
    bool flag = true;
    for (int i = 0; i < n; i++)
      if (la[i] == 0) flag = false;
    if (!flag) continue;
    memset(d, -1, sizeof(d));
    d[0][0] = 0;
    int now = -1;
    for (int mask = 0; mask < (1 << n); mask++)
      for (int inv = 0; inv <= u; inv++)
        if (d[mask][inv] != -1)
          if (mask == (1 << n) - 1) {
            now = inv;
            break;
          } else
            for (int i = n - 1, tot = 0; i >= 0; i--) {
              if (mask & (1 << i))
                tot++;
              else {
                int id = lower_bound(a[i], a[i] + la[i], d[mask][inv]) - a[i];
                if (id < la[i])
                  update(d[mask | (1 << i)][inv + tot], a[i][id] + 1);
              }
            }
    if (now < res) res = now, id = t;
  }
  if (res == 123456)
    printf("Brand new problem!\n");
  else {
    printf("%d\n[:", id);
    for (int i = u - res + 1; i > 0; i--) putchar('|');
    printf(":]\n");
  }
  return 0;
}
