#include <bits/stdc++.h>
using namespace std;
const int N = 300;
int n, m, k, len, mn = N, num = -1, cnum;
string s[5], q[20];
void calc(int mask, vector<int> curr) {
  int i, j, inv = 0;
  if ((int(curr.size())) == n) {
    int pos = 1;
    for (i = 0; i < (int(curr.size())); i++) {
      while ((pos <= k) && (s[curr[i]] != q[pos])) {
        pos++;
      }
      if (pos == k + 1) {
        break;
      }
      pos++;
      for (j = i + 1; j < (int(curr.size())); j++) {
        if (curr[i] > curr[j]) {
          inv++;
        }
      }
    }
    if (i == (int(curr.size()))) {
      if (inv < mn) {
        num = cnum;
        mn = inv;
      }
    }
    return;
  }
  for (i = 3; i >= 0; i--) {
    if (((mask >> i) & 1) == 0) {
      curr.push_back(i + 1);
      calc(mask + (1 << i), curr);
      curr.erase(curr.begin() + (int(curr.size())) - 1);
    }
  }
}
int main() {
  scanf("%d\n", &n);
  int i, j;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
  }
  scanf("%d\n", &m);
  for (i = 1; i <= m; i++) {
    scanf("%d", &k);
    for (j = 1; j <= k; j++) {
      cin >> q[j];
    }
    vector<int> tmp;
    cnum = i;
    calc(0, tmp);
  }
  if (mn == N) {
    cout << "Brand new problem!";
  } else {
    cout << num << endl << "[:";
    for (i = 1; i <= n * (n - 1) / 2 - mn + 1; i++) {
      cout << "|";
    }
    cout << ":]";
  }
  return 0;
}
