#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 10;
const int maxv = 1e3 + 10;
const double eps = 1e-9;
int n;
int m;
string s[10];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    scanf("%d", &m);
    int rid = 1;
    int ans = 0;
    for (int kk = 1; kk <= m; kk++) {
      vector<string> v;
      int c;
      scanf("%d", &c);
      for (int i = 0; i < c; i++) {
        string tmp;
        cin >> tmp;
        v.push_back(tmp);
      }
      int id[4] = {0, 1, 2, 3};
      int cnt = inf;
      do {
        int st = 0;
        for (int i = 0; i < c && st < n; i++) {
          if (v[i] == s[id[st]]) st++;
        }
        if (st == n) {
          int ncnt = 0;
          for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
              if (id[i] < id[j]) ncnt++;
            }
          }
          cnt = min(cnt, ncnt);
        }
      } while (next_permutation(id, id + n));
      if (cnt == inf) continue;
      if (n * (n - 1) / 2 - cnt + 1 > ans) {
        ans = n * (n - 1) / 2 - cnt + 1;
        rid = kk;
      }
    }
    if (ans == 0) {
      puts("Brand new problem!");
      continue;
    }
    printf("%d\n", rid);
    printf("[:");
    while (ans--) printf("|");
    printf(":]");
    puts("");
  }
  return 0;
}
