#include <bits/stdc++.h>
using namespace std;
template <typename Iter>
ostream& _out(ostream& s, Iter a, Iter b) {
  for (auto it = a; it != b; it++) s << (it == a ? "" : " ") << *it;
  return s;
}
template <typename A, typename B>
ostream& operator<<(ostream& s, pair<A, B>& p) {
  return s << "(" << p.first << " , " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T>& v) {
  return _out(s, v.begin(), v.end());
}
inline long long rit() {
  int key = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') key = -1;
    c = getchar();
  }
  long long x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * key;
}
int __ = 1;
void init() {}
void read() {}
void solve() {}
string a[10], a0[10];
vector<string> b[20];
int main() {
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a0[i] = a[i];
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      string s;
      cin >> s;
      b[i].push_back(s);
    }
  }
  int best = 0x3f3f3f3f, pos;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 300; j++) {
      random_shuffle(a, a + n);
      int ok = 1, now = 0;
      for (int k = 0; k < b[i].size(); k++) {
        if (b[i][k] == a[now]) {
          now++;
          if (now == n) break;
        }
      }
      if (now == n) {
        int cnt = 0;
        for (int x = 0; x < n; x++) {
          for (int y = x + 1; y < n; y++) {
            for (int s = 0; s < n; s++) {
              for (int s2 = 0; s2 < s; s2++) {
                if (a[x] == a0[s] && a[y] == a0[s2]) {
                  cnt++;
                }
              }
            }
          }
        }
        if (cnt < best) pos = i, best = cnt;
      }
    }
  }
  if (best == 0x3f3f3f3f) {
    cout << "Brand new problem!\n";
    return 0;
  } else {
    cout << pos + 1 << endl;
    cout << "[:";
    for (int i = 0; i < n * (n - 1) / 2 - best + 1; i++) cout << "|";
    cout << ":]\n";
    return 0;
  }
  return 0;
}
