#include <bits/stdc++.h>
using namespace std;
int vis[15];
int a[25];
int x;
int n;
int mx;
void dfs(int now, int dep, int kui) {
  if (now == n) {
    mx = min(mx, kui);
    return;
  }
  if (dep >= x) return;
  dfs(now, dep + 1, kui);
  if (!vis[a[dep]] && a[dep]) {
    vis[a[dep]] = 1;
    for (int i = a[dep] + 1; i <= n; i++)
      if (vis[i]) kui++;
    dfs(now + 1, dep + 1, kui);
    vis[a[dep]] = 0;
  }
}
int main(int argc, char** argv) {
  cin >> n;
  map<string, int> id;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    id[s] = i;
  }
  int m;
  cin >> m;
  int mxp = 0, mmx = 1e9, ans = 0, cc = 0;
  for (int i = 1; i <= m; i++) {
    memset(vis, 0, sizeof(vis));
    cin >> x;
    mx = 1e9;
    for (int j = 1; j <= x; j++) {
      string s;
      cin >> s;
      a[j - 1] = id[s];
    }
    dfs(0, 0, 0);
    if (mx < mmx) {
      ans = i;
      mmx = mx;
      cc = 1;
    }
  }
  if (ans) {
    cout << ans << endl;
    cout << "[:";
    for (int i = 1; i <= (n * (n - 1)) / 2 - mmx + 1; i++) cout << "|";
    cout << ":]";
  } else
    printf("Brand new problem!");
  return 0;
}
