#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int n, m, formula;
int max_p = 0;
int max_num = 0;
vector<string> PR;
vector<string> read() {
  int k;
  vector<string> t;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    string t1;
    cin >> t1;
    t.push_back(t1);
  }
  return t;
}
int inv(vector<int> ps) {
  int x = 0;
  for (int i = 0; i < n; i++) {
    int token = ps[i];
    for (int j = i + 1; j < n; j++) {
      if (ps[j] < token) {
        ++x;
      }
    }
  }
  return x;
}
int check(vector<string> t) {
  vector<string>::iterator it;
  vector<vector<int> > ps, ps_mutator;
  for (int i = 0; i < n; i++) {
    vector<int> row;
    for (int j = 0; j < t.size(); j++) {
      if (t[j] == PR[i]) {
        row.push_back(j);
      }
    }
    if (row.size() == 0) {
      return 0;
    } else {
      ps_mutator.clear();
      ps_mutator.resize(ps.size());
      copy(ps.begin(), ps.end(), ps_mutator.begin());
      ps.clear();
      for (int k = 0; k < row.size(); k++) {
        if (ps_mutator.size() > 0) {
          for (int l = 0; l < ps_mutator.size(); l++) {
            vector<int> proxy(ps_mutator[l].size());
            copy(ps_mutator[l].begin(), ps_mutator[l].end(), proxy.begin());
            proxy.push_back(row[k]);
            ps.push_back(proxy);
          }
        } else {
          vector<int> proxy;
          proxy.push_back(row[k]);
          ps.push_back(proxy);
        }
      }
    }
  }
  int MIN = 1000;
  for (int s = 0; s < ps.size(); s++) {
    MIN = min(inv(ps[s]), MIN);
  }
  return formula - MIN;
}
int main(int argc, char **argv) {
  cin >> n;
  formula = (n * (n - 1) / 2) + 1;
  for (int i = 0; i < n; ++i) {
    string t;
    cin >> t;
    PR.push_back(t);
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int p = check(read());
    if (p > max_p) {
      max_p = p;
      max_num = i + 1;
    }
  }
  if (max_p == 0) {
    cout << "Brand new problem!" << endl;
  } else {
    cout << max_num << endl;
    cout << "[:";
    for (int i = 0; i < max_p; ++i) {
      cout << "|";
    }
    cout << ":]" << endl;
  }
}
