#include <bits/stdc++.h>
const long long inf = 1e9;
const long long mod = 1e9 + 7;
const long long zero = 0;
const long long maxn = 1e2 + 5;
using namespace std;
long long n, m, k, z, v, p[maxn];
string s[maxn], c[maxn];
void dfs(long long x, long long y) {
  if (x == n) {
    int u = 0;
    for (int j = 0; j < n; j++)
      for (int i = 0; i < j; i++)
        if (p[i] > p[j]) u++;
    if (z < (n - 1) * n / 2 - u + 1) z = (n - 1) * n / 2 - u + 1, v = y;
    return;
  }
  for (int i = 0; i < k; i++)
    if (s[x] == c[i]) {
      p[x] = i;
      dfs(x + 1, y);
    }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) cin >> c[j];
    dfs(0, i + 1);
  }
  if (v)
    cout << v << endl << "[:" << string(z, '|') << ":]" << endl;
  else
    puts("Brand new problem!");
}
