#include <bits/stdc++.h>
using namespace std;
set<string> ss;
vector<string> v;
int a[4], n, m, k, c[4], p, mx = -1, nn;
vector<vector<int>> b;
vector<pair<int, vector<int>>> per;
vector<int> pp;
string s;
int fact(int n) {
  int k = 1;
  for (int i = 1; i <= n; i++) {
    k *= i;
  }
  return k;
}
int inv(const vector<int> &v) {
  int c = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (v[i] < v[j]) c++;
    }
  }
  return c;
}
void rec(int h) {
  if (h == n) {
    per.push_back(make_pair(inv(pp), pp));
  } else {
    for (int i = 0; i < n; i++) {
      if (c[i] == 0) {
        c[i] = 1;
        pp[h] = i;
        rec(h + 1);
        c[i] = 0;
      }
    }
  }
}
bool posl(vector<int> &v1, vector<int> &v2) {
  int k = 0;
  int c = 0;
  for (int i = 0; i < v2.size(); i++) {
    for (int j = k; j < v1.size(); j++) {
      k++;
      if (v1[j] == v2[i]) {
        c = 1;
        break;
      }
    }
    if (k == v1.size() && c == 0) {
      return false;
    }
    c = 0;
  }
  return true;
}
int poh(vector<int> &v1, pair<int, vector<int>> &p) {
  if (posl(v1, p.second)) {
    return n * (n - 1) / 2 - p.first + 1;
  } else {
    return 0;
  }
}
int main() {
  cin >> n;
  pp.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (ss.find(s) != ss.end()) {
      for (int j = 0; j < v.size(); j++) {
        if (v[j] == s) {
          a[i] = j;
          break;
        }
      }
    } else {
      a[i] = v.size();
      ss.insert(s);
      v.push_back(s);
    }
  }
  cin >> m;
  b.resize(m);
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> s;
      if (ss.find(s) != ss.end()) {
        for (int j = 0; j < v.size(); j++) {
          if (v[j] == s) {
            b[i].push_back(j);
            break;
          }
        }
      } else {
        b[i].push_back(v.size());
        ss.insert(s);
        v.push_back(s);
      }
    }
  }
  rec(0);
  for (int i = 0; i < m; i++) {
    int p = 0, h = 0;
    for (int j = 0; j < per.size(); j++) {
      int x = poh(b[i], per[j]);
      if (p < x) {
        p = x;
        h = i;
      }
    }
    if (mx < p) {
      mx = p;
      nn = h;
    }
  }
  if (mx == 0) {
    cout << "Brand new problem!" << endl;
  } else {
    cout << nn + 1 << endl;
    cout << "[:";
    for (int i = 0; i < mx; i++) {
      cout << '|';
    }
    cout << ":]" << endl;
  }
  return 0;
}
