#include <bits/stdc++.h>
using namespace std;
const int N = 300;
map<string, int> mp;
int n, m, k, ansL, ansV, cnt, a[5], c[5], b[20][30], lb[20];
bool newPro;
bool used[5];
int dp[5][30];
int max(int a, int b) { return (a > b) ? a : b; }
bool IsSub(int r) {
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= lb[r]; j++) {
      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      if (c[i] == b[r][j]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
    }
  if (dp[n][lb[r]] == n)
    return true;
  else
    return false;
}
void FindAns() {
  int x = 0;
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++)
      if (c[i] > c[j]) x++;
  for (int i = 1; i <= m; i++) {
    if (IsSub(i)) {
      newPro = false;
      if (x < ansV || (x == ansV && i < ansL)) {
        ansV = x;
        ansL = i;
        cnt = n * (n - 1) / 2 - x + 1;
      }
    }
  }
}
void Dfs(int p, int q) {
  c[p] = q;
  used[q] = true;
  if (p == n) {
    FindAns();
    used[q] = false;
    return;
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) Dfs(p + 1, i);
  used[q] = false;
}
void Solve() {
  newPro = true;
  ansV = 10000;
  ansL = m + 1;
  memset(used, false, sizeof(used));
  for (int i = 1; i <= n; i++) {
    Dfs(1, i);
  }
  if (newPro)
    puts("Brand new problem!");
  else {
    cout << ansL << endl;
    cout << "[:";
    for (int i = 1; i <= cnt; i++) cout << "|";
    cout << ":]" << endl;
  }
}
int main() {
  mp.clear();
  k = 0;
  cin >> n;
  string t;
  for (int i = 1; i <= n; i++) {
    cin >> t;
    if (mp[t] != 0)
      a[i] = mp[t];
    else {
      mp[t] = ++k;
      a[i] = mp[t];
    }
  }
  memset(lb, 0, sizeof(lb));
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> lb[i];
    for (int j = 1; j <= lb[i]; j++) {
      cin >> t;
      if (mp[t] != 0)
        b[i][j] = mp[t];
      else {
        mp[t] = ++k;
        b[i][j] = mp[t];
      }
    }
  }
  Solve();
  return 0;
}
