#include <bits/stdc++.h>
using namespace std;
char s[101];
map<string, int> mp;
int n, res, Res, m, v, a[501000], nt[501000][17], dp[60000][230], Nt[20];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    mp[s] = i;
  }
  scanf("%d", &m);
  res = n * (n - 1) / 2 + 1;
  for (int _ = 0; _ < m; _++) {
    scanf("%d", &v);
    for (int i = 0; i < n; i++) Nt[i] = v;
    for (int j = 0; j < v; j++) {
      scanf("%s", s);
      a[j] = mp.count(s) ? mp[s] : -1;
    }
    for (int j = v; j >= 0; j--) {
      if (a[j] != -1) Nt[a[j]] = j;
      for (int k = 0; k < n; k++) nt[j][k] = Nt[k];
    }
    memset(dp, 0x7f, sizeof(dp));
    dp[0][0] = -1;
    for (int i = 0; i < (1 << n); i++)
      for (int j = 0; j < res; j++)
        if (dp[i][j] < v)
          for (int k = 0; k < n; k++)
            if ((~i >> k) & 1)
              if (dp[i + (1 << k)][j + __builtin_popcount(i >> k)] >
                  nt[dp[i][j] + 1][k])
                dp[i + (1 << k)][j + __builtin_popcount(i >> k)] =
                    nt[dp[i][j] + 1][k];
    for (int i = 0; i < res; i++)
      if (dp[(1 << n) - 1][i] < v) res = i, Res = _;
  }
  res = n * (n - 1) / 2 + 1 - res;
  if (res) {
    printf("%d\n[:", Res + 1);
    for (int i = 0; i < res; i++) printf("|");
    puts(":]");
  } else
    puts("Brand new problem!");
}
