#include <bits/stdc++.h>
using namespace std;
const int INF = ~(1 << 31);
inline int in() {
  int a;
  scanf("%d", &a);
  return a;
}
template <class T1, class T2>
inline pair<T1, T2> reverse_make_pair(T1 x, T2 y) {
  return pair<T1, T2>(y, x);
}
template <class T>
ostream& operator<<(ostream& out, const vector<T> a) {
  for (int i = 0; i < (int)a.size() - 1; i++) out << a[i] << ' ';
  if (a.size() >= 1) cout << a[a.size() - 1];
  return out;
}
double din() {
  double a;
  scanf("%lf", &a);
  return a;
}
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const double eps = 1e-6;
int logbin(int a) {
  a--;
  int res = 1;
  while (a) a >>= 1, res <<= 1;
  return res;
}
int binpow(int a, int n) {
  int res = 1;
  while (n) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
struct treap {
  treap *l, *r;
  int y, x;
  int size;
  treap(int xx) {
    l = r = NULL;
    y = rand();
    x = xx;
    size = 0;
    recalc();
  }
  void recalc() {
    size = 1;
    if (l) size += l->size;
    if (r) size += r->size;
  }
};
void recalc(treap*& a) {
  if (a == NULL) return;
  a->recalc();
}
void merge(treap*& t, treap* l, treap* r) {
  if (l == NULL) return (void)(t = r);
  if (r == NULL) return (void)(t = l);
  if (r->y > l->y) {
    merge(r->l, l, r->l);
    t = r;
  } else {
    merge(l->r, l->r, r);
    t = l;
  }
  recalc(t);
}
void split(treap* v, int x, treap*& l, treap*& r) {
  if (v == NULL) return (void)(r = l = NULL);
  if (v->x <= x) {
    split(v->r, x, v->r, r);
    l = v;
  } else {
    split(v->l, x, l, v->l);
    r = v;
  }
  recalc(v);
}
int getinv(vector<int> N) {
  int buf, e = 0;
  for (int i = 0; i < N.size(); i++) {
    for (int s = 0; s < N.size() - i - 1; s++) {
      if (N[s + 1] < N[s]) {
        buf = N[s];
        N[s] = N[s + 1];
        N[s + 1] = buf;
        e++;
      }
    }
  }
  return e;
}
int main() {
  int n = in();
  vector<int> a;
  int count = 0;
  map<string, int> st;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    st[s] = count++;
    a.push_back(st[s]);
  }
  int m = in();
  vector<vector<int> > g(m, vector<int>());
  for (int i = 0; i < m; ++i) {
    int k = in();
    for (int j = 0; j < k; ++j) {
      string s;
      cin >> s;
      if (st.count(s) == 0) st[s] = count++;
      g[i].push_back(st[s]);
    }
  }
  int res = -1;
  int inv = INF;
  do {
    for (int i = 0; i < m; ++i) {
      int k = 0;
      for (int j = 0; j < g[i].size() && k < a.size(); ++j) {
        if (a[k] == g[i][j]) {
          ++k;
        }
      }
      if (k == a.size()) {
        int in = getinv(a);
        if (in < inv || (in == inv && i < res)) {
          inv = in;
          res = i;
        }
      }
    }
  } while (next_permutation((a).begin(), (a).end()));
  if (res == -1) {
    cout << "Brand new problem!\n";
  } else {
    cout << res + 1 << endl;
    cout << "[:";
    int p = ((a.size() - 1) * a.size()) / 2 - inv + 1;
    for (int i = 0; i < p; ++i) {
      cout << "|";
    }
    cout << ":]" << endl;
  }
  return 0;
}
