#include <bits/stdc++.h>
using namespace std;
int mask[1 << 15];
int add[1 << 15][15];
int high[15];
vector<string> sList;
pair<int, int> ans;
vector<string> inline flatInput(int n, int k) {
  vector<string> lv1;
  for (int i = 0; i < n; i++) high[i] = -1;
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    int highId = -1;
    int idx = -1;
    for (int j = 0; j < n; j++) {
      if (sList[j] == s) {
        idx = j;
        break;
      }
      highId = max(highId, high[j]);
    }
    if (idx == -1 || highId < high[idx]) continue;
    high[idx] = i;
    lv1.push_back(s);
  }
  vector<string> lv2;
  for (int i = 0; i < n; i++) high[i] = k + 1;
  for (int i = lv1.size() - 1; i >= 0; i--) {
    string s = lv1[i];
    int lowId = k + 1;
    int idx = -1;
    for (int j = n - 1; j >= 0; j--) {
      if (sList[j] == s) {
        idx = j;
        break;
      }
      lowId = min(lowId, high[j]);
    }
    if (idx == -1 || lowId > high[idx]) continue;
    high[idx] = i;
    lv2.push_back(s);
  }
  vector<string> lv3;
  for (int i = lv2.size() - 1; i >= 0; i--) lv3.push_back(lv2[i]);
  return lv3;
}
int main() {
  ios_base::sync_with_stdio();
  ans = make_pair(1000, 1000);
  int n;
  cin >> n;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      add[i][j] = 0;
      if (i & (1 << j))
        ;
      else {
        for (int k = j + 1; k < n; k++) {
          if (i & (1 << k)) add[i][j]++;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    string k;
    cin >> k;
    sList.push_back(k);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int set = 0; set < (1 << n); set++) mask[set] = 1000;
    mask[0] = 0;
    string last = "";
    vector<string> input = flatInput(n, k);
    for (int j = 0; j < input.size(); j++) {
      string l = input[j];
      int idx = -1;
      for (int id = 0; id < n; id++) {
        if (sList[id] == l) {
          idx = id;
          break;
        }
      }
      if (idx == -1) continue;
      for (int bit = (1 << n) - 1; bit > 0; bit--) {
        if ((1 << idx) & bit) {
          int bef = bit - (1 << idx);
          int cnt = mask[bef];
          if (cnt >= 1000) continue;
          mask[bit] = min(mask[bit], cnt + add[bef][idx]);
        }
      }
      if (mask[(1 << n) - 1] != 1000) {
        if (ans.second > mask[(1 << n) - 1]) {
          ans.first = i;
          ans.second = mask[(1 << n) - 1];
        }
      }
    }
  }
  if (ans.second == 1000) {
    cout << "Brand new problem!" << endl;
  } else {
    cout << ans.first + 1 << endl;
    cout << "[:";
    int cnt = n * (n - 1) / 2 - ans.second + 1;
    for (int i = 0; i < cnt; i++) cout << "|";
    cout << ":]" << endl;
  }
}
