#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<string> _lesha(n);
  for (int i = 0; i < n; ++i) {
    cin >> _lesha[i];
  }
  int M;
  cin >> M;
  bool found = false;
  int best_score = -1;
  int best_index = -1;
  for (int m = 0; m < M; ++m) {
    int word_num;
    cin >> word_num;
    vector<string> archive(word_num);
    for (int j = 0; j < word_num; ++j) {
      cin >> archive[j];
    }
    vector<int> shff(n);
    for (int j = 0; j < shff.size(); ++j) {
      shff[j] = j;
    }
    do {
      vector<string> lesha(n);
      for (int j = 0; j < n; ++j) {
        lesha[j] = _lesha[shff[j]];
      }
      bool isOk = true;
      vector<string>::iterator char_pos =
          find(archive.begin(), archive.end(), lesha[0]);
      if (char_pos == archive.end()) {
        isOk = false;
      }
      for (int j = 1; j < lesha.size(); ++j) {
        vector<string>::iterator next_char_pos =
            find(char_pos + 1, archive.end(), lesha[j]);
        if (next_char_pos == archive.end()) {
          isOk = false;
          break;
        }
        char_pos = next_char_pos;
      }
      if (isOk) {
        int x = 0;
        for (int j = 0; j < shff.size() - 1; ++j) {
          for (int k = j + 1; k < shff.size(); ++k) {
            if (shff[j] > shff[k]) {
              ++x;
            }
          }
        }
        int score = lesha.size() * (lesha.size() - 1) / 2 - x + 1;
        if (score > best_score) {
          best_score = score;
          best_index = m;
        }
      }
    } while (next_permutation(shff.begin(), shff.end()));
  }
  if (best_index < 0) {
    cout << "Brand new problem!" << endl;
  } else {
    cout << (best_index + 1) << endl;
    cout << "[:";
    for (int j = 0; j < best_score; ++j) {
      cout << "|";
    }
    cout << ":]" << endl;
  }
  return 0;
}
