#include <bits/stdc++.h>
using namespace std;
int inverse(vector<string> owords, vector<string> words) {
  vector<int> p(owords.size());
  for (int(i) = 0; (i) < (words.size()); (i)++) {
    for (int(j) = 0; (j) < (owords.size()); (j)++)
      if (words[i] == owords[j]) p[i] = j;
  }
  int cnt = 0;
  for (int(i) = 0; (i) < (words.size()); (i)++) {
    for (int j = 0; j < i; j++) {
      if (i > j && p[i] < p[j]) cnt++;
    }
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  while (cin >> n) {
    vector<string> words;
    for (int(i) = 0; (i) < (n); (i)++) {
      string s;
      cin >> s;
      words.push_back(s);
    }
    vector<string> owords = words;
    sort(words.begin(), words.end());
    vector<string> swords = words;
    int m;
    cin >> m;
    int maxidx = -1;
    int maxidxp = 0;
    for (int(i) = 0; (i) < (m); (i)++) {
      words = swords;
      int k;
      cin >> k;
      vector<string> words1;
      for (int(j) = 0; (j) < (k); (j)++) {
        string s;
        cin >> s;
        words1.push_back(s);
      }
      do {
        int wordidx = 0;
        int word1idx = 0;
        while (true) {
          if (wordidx >= words.size() || word1idx >= words1.size()) break;
          if (words[wordidx] != words1[word1idx])
            word1idx++;
          else {
            wordidx++;
            word1idx++;
          }
        }
        if (wordidx == words.size()) {
          int x = inverse(owords, words);
          int n = words.size();
          int p = n * (n - 1) / 2 - x + 1;
          if (maxidx == -1 || p > maxidxp) maxidxp = p, maxidx = i + 1;
        }
      } while (next_permutation(words.begin(), words.end()));
    }
    if (maxidx == -1) {
      cout << "Brand new problem!" << endl;
    } else {
      cout << maxidx << endl;
      cout << "[:";
      for (int(i) = 0; (i) < (maxidxp); (i)++) cout << "|";
      cout << ":]" << endl;
    }
  }
}
