#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
const int p = 271;
const int mod = 1000000007;
const int inf = 1000000000;
int sh[20];
int a[11][500050];
int k[15];
int dp[40000][150];
int st[20];
int main() {
  int n, m;
  cin >> n;
  char s[15];
  for (int i = 0; i < n; i++) {
    long long st = 1;
    scanf("%s", s);
    int l = strlen(s);
    sh[i] = 0;
    for (int j = 0; j < l; j++) {
      sh[i] = (sh[i] + s[j] * st) % mod;
      st = st * p % mod;
    }
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d", k + i);
    for (int j = 0; j < k[i]; j++) {
      scanf("%s", s);
      int l = strlen(s);
      a[i][j] = 0;
      long long st = 1;
      for (int i1 = 0; i1 < l; i1++) {
        a[i][j] = (a[i][j] + s[i1] * st) % mod;
        st = st * p % mod;
      }
    }
  }
  st[0] = 1;
  for (int i = 1; i < 20; i++) st[i] = st[i - 1] * 2;
  int maxmask = st[n];
  int maxinv = n * (n - 1) / 2;
  int mininv = maxinv + 1;
  int mini;
  bool was = false;
  vector<vector<int>> wordpos(n);
  for (int cur = 0; cur < m; cur++) {
    for (int i = 0; i < n; i++) wordpos[i].clear();
    for (int i = 0; i < k[cur]; i++)
      for (int j = 0; j < n; j++)
        if (a[cur][i] == sh[j]) wordpos[j].push_back(i);
    bool flag = true;
    for (int i = 0; i < n; i++)
      if (wordpos[i].empty()) flag = false;
    for (int i = 0; i < maxmask; i++)
      for (int j = 0; j <= maxinv; j++) dp[i][j] = inf;
    dp[0][0] = -1;
    for (int mask = 0; mask < maxmask; mask++) {
      int kolinv = 0;
      for (int i = 0; i < n; i++)
        if (mask & st[i]) kolinv++;
      kolinv = kolinv * (kolinv - 1) / 2;
      kolinv = min(kolinv, mininv - 1);
      for (int inv = 0; inv <= kolinv; inv++)
        if (dp[mask][inv] != inf) {
          int d = 0;
          for (int i = n - 1; i >= 0; i--)
            if (!(mask & st[i])) {
              vector<int>::iterator it;
              it = upper_bound(wordpos[i].begin(), wordpos[i].end(),
                               dp[mask][inv]);
              if (it != wordpos[i].end())
                dp[mask ^ st[i]][inv + d] = min(dp[mask ^ st[i]][inv + d], *it);
            } else
              d++;
        }
    }
    for (int inv = 0; inv < mininv; inv++)
      if (dp[maxmask - 1][inv] != inf) {
        was = true;
        mininv = inv;
        mini = cur;
        break;
      }
  }
  if (!was)
    printf("Brand new problem!\n");
  else {
    int p = maxinv - mininv + 1;
    printf("%d\n[:", mini + 1);
    for (int i = 0; i < p; i++) printf("|");
    printf(":]\n");
  }
  return 0;
}
