#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int n, k, g;
string s[4];
int main() {
  cin >> n;
  int g = n * (n - 1) / 2 + 1;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    a.push_back(i);
  }
  cin >> k;
  int p = 500000000;
  int mn = 11;
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    string t[22];
    for (int j = 0; j < x; j++) cin >> t[j];
    vector<int> b;
    for (int q = 0; q < a.size(); q++) b.push_back(a[q]);
    do {
      int l1 = 0;
      int l2 = 0;
      bool ok = false;
      while (l1 < n && l2 < x) {
        if (s[b[l1]] == t[l2]) l1++;
        l2++;
        if (l1 == n) ok = true;
      }
      int in = 0;
      for (int j = 0; j < b.size(); j++)
        for (int k = j + 1; k < b.size(); k++) {
          if (b[k] < b[j]) in++;
        }
      int ph = g - in;
      if (ok) {
        if (mn == 11 || ph > p) {
          p = ph;
          mn = i;
        }
      }
    } while (next_permutation(b.begin(), b.end()));
  }
  if (mn == 11)
    cout << "Brand new problem!";
  else {
    cout << mn + 1 << endl;
    cout << "[:";
    for (int i = 0; i < p; i++) cout << '|';
    cout << ":]";
  }
  return 0;
}
