#include <bits/stdc++.h>
using namespace std;
const int maxint = 1 << 30;
string word[100];
string p[500];
int a[100];
int n;
int main() {
  while (cin >> n) {
    for (int i = 1; i <= n; i++) cin >> word[i];
    int m;
    cin >> m;
    int id = -1;
    int sim = 0;
    for (int k = 1; k <= m; k++) {
      int num;
      cin >> num;
      for (int i = 1; i <= num; i++) cin >> p[i];
      for (int i = 1; i <= n; i++) a[i] = i;
      int pp = maxint;
      do {
        int x = 1, y = 1;
        while (x <= n && y <= num) {
          if (word[a[x]] == p[y]) {
            x++;
          }
          y++;
        }
        if (x > n) {
          int fuck = 0;
          for (int i = 2; i <= n; i++)
            for (int j = 1; j <= i - 1; j++)
              if (a[j] > a[i]) fuck++;
          pp = min(pp, fuck);
        }
      } while (next_permutation(a + 1, a + n + 1));
      if (pp != maxint) {
        pp = n * (n - 1) / 2 - pp + 1;
        if (pp > sim) {
          sim = pp;
          id = k;
        }
      }
    }
    if (id == -1)
      puts("Brand new problem!");
    else {
      printf("%d\n", id);
      cout << "[:";
      for (int i = 1; i <= sim; i++) cout << "|";
      cout << ":]" << endl;
    }
  }
  return 0;
}
