#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<string> a, b[20];
bool p[20] = {};
int ans[20] = {};
void rec(int tnum, int wnum, int c, int st, int pnum) {
  if (st >= b[tnum].size()) return;
  while (st < b[tnum].size() && b[tnum][st] != a[wnum]) st++;
  if (st >= b[tnum].size()) return;
  p[wnum] = true;
  for (int i = wnum + 1; i < a.size(); i++)
    if (p[i]) pnum++;
  if (c == a.size())
    ans[tnum] = max(ans[tnum], n * (n - 1) / 2 - pnum + 1);
  else
    for (int i = 0; i < a.size(); i++)
      if (!p[i]) rec(tnum, i, c + 1, st + 1, pnum);
  p[wnum] = false;
}
int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    b[i].resize(k);
    for (int j = 0; j < k; j++) cin >> b[i][j];
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) rec(i, j, 1, 0, 0);
  int maxp = 0;
  for (int i = 1; i < m; i++)
    if (ans[i] > ans[maxp]) maxp = i;
  if (ans[maxp]) {
    cout << maxp + 1 << endl;
    cout << "[:";
    for (int i = 0; i < ans[maxp]; i++) cout << "|";
    cout << ":]";
  } else
    cout << "Brand new problem!";
}
