#include <bits/stdc++.h>
using namespace std;
const int MX = int(1e6);
int inv_count(vector<int>& tmp) {
  int cnt = 0, n = int(tmp.size());
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (tmp[j] > tmp[j + 1]) {
        cnt++;
        swap(tmp[j], tmp[j + 1]);
      }
    }
  }
  return cnt;
}
int get_min(int i, vector<int>& tmp, vector<int> A, int k, int n, int msk) {
  if (int(A.size()) == n) {
    if (msk == ((1 << n) - 1)) {
      return inv_count(A);
    } else
      return MX;
  }
  int ans = MX;
  if (i == int(tmp.size())) return MX;
  ans = min(ans, get_min(i + 1, tmp, A, k, n, msk));
  A.push_back(tmp[i]);
  ans = min(ans, get_min(i + 1, tmp, A, k, n, msk | (1 << tmp[i])));
  A.pop_back();
  return ans;
}
pair<int, int> get(vector<string>& A, vector<string>& B, int n, int k,
                   int idx) {
  pair<int, int> ans(idx, MX);
  vector<int> tmp;
  for (int j = 0; j < k; j++) {
    for (int i = 0; i < n; i++) {
      if (B[j] == A[i]) {
        tmp.push_back(i);
        break;
      }
    }
  }
  ans.second = get_min(0, tmp, vector<int>(), k, n, 0);
  return ans;
}
void solve() {
  int n, m, k, p, x;
  cin >> n;
  vector<string> A(n), B;
  for (int i = 0; i < n; i++) cin >> A[i];
  cin >> m;
  pair<int, int> ans = make_pair(-1, MX);
  for (int i = 0; i < m; i++) {
    cin >> k;
    B = vector<string>(k);
    for (int j = 0; j < k; j++) cin >> B[j];
    pair<int, int> tmp = get(A, B, n, k, i);
    if (tmp.second != MX && ans.second > tmp.second) ans = tmp;
  }
  if (ans.second == MX) {
    puts("Brand new problem!");
  } else {
    cout << 1 + ans.first << "\n[:";
    ans.second = n * (n - 1) / 2 - ans.second + 1;
    while (ans.second--) cout << '|';
    cout << ":]\n";
  }
}
int main() { solve(); }
