#include <bits/stdc++.h>
using namespace std;
int inv1(int a) { return 0; }
int inv2(int a, int b) { return a > b; }
int inv3(int a, int b, int c) { return (a > b) + (a > c) + (b > c); }
int inv4(int a, int b, int c, int d) {
  return (a > b) + (a > c) + (a > d) + (b > c) + (b > d) + (c > d);
}
int main() {
  string s[4], str;
  int y[4], g[10], o = -1, mi = -1;
  int n, m, a;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    map<string, int> d;
    map<string, vector<int> > k;
    cin >> a;
    for (int j = 0; j < a; j++) {
      cin >> str;
      d[str] = 1;
      k[str].push_back(j);
    }
    bool OK = 1;
    for (int j = 0; j < n; j++)
      if (d[s[j]] == 0) OK = 0;
    if (OK) {
      int inv = 100;
      if (n == 1) inv = 0;
      if (n == 2) {
        for (int j = 0; j < k[s[0]].size(); j++)
          for (int h = 0; h < k[s[1]].size(); h++) {
            int x = inv2(k[s[0]][j], k[s[1]][h]);
            if (x < inv) inv = x;
          }
      }
      if (n == 3) {
        for (int j = 0; j < k[s[0]].size(); j++)
          for (int h = 0; h < k[s[1]].size(); h++)
            for (int f = 0; f < k[s[2]].size(); f++) {
              int x = inv3(k[s[0]][j], k[s[1]][h], k[s[2]][f]);
              if (x < inv) inv = x;
            }
      }
      if (n == 4) {
        for (int j = 0; j < k[s[0]].size(); j++)
          for (int h = 0; h < k[s[1]].size(); h++)
            for (int f = 0; f < k[s[2]].size(); f++)
              for (int b = 0; b < k[s[3]].size(); b++) {
                int x = inv4(k[s[0]][j], k[s[1]][h], k[s[2]][f], k[s[3]][b]);
                if (x < inv) inv = x;
              }
      }
      int p = n * (n - 1) / 2 - inv + 1;
      if (p > mi) {
        mi = p;
        o = i;
      }
    }
  }
  if (o != -1) {
    cout << o + 1 << endl << "[:";
    for (int k = 1; k <= mi; k++) cout << "|";
    cout << ":]";
  } else
    cout << "Brand new problem!";
}
