#include <bits/stdc++.h>
using namespace std;
int g[500002][16], f[33002][106], pos[16], inv[16];
char a[16][11], b[500002][11];
int n, m, t, ans, id;
void init() { ans = 0x3f3f3f3f; }
int main() {
  scanf("%d", &n);
  init();
  for (int i = 1; i <= n; ++i) scanf("%s", a[i]);
  scanf("%d", &t);
  for (int l = 1; l <= t; ++l) {
    scanf("%d", &m);
    for (int i = 1; i <= m; ++i) scanf("%s", b[i]);
    for (int i = 1; i <= n; ++i) g[m + 1][i] = 0x3f3f3f3f;
    for (int i = m; i; --i) {
      for (int j = 1; j <= n; ++j) g[i][j] = g[i + 1][j];
      for (int j = 1; j <= n; ++j)
        if (strcmp(a[j], b[i]) == 0) g[i][j] = i;
    }
    memset(f, 0x3f3f3f3f, sizeof(f));
    f[0][0] = 0;
    for (int i = 0; i < (1 << n) - 1; ++i) {
      memset(inv, 0, sizeof(inv));
      int count = 0;
      for (int j = n - 1; j >= 0; --j) {
        if ((i & (1 << j)) == 0) {
          pos[count++] = j, inv[count] = count ? inv[count - 1] : 0;
        } else
          ++inv[count];
      }
      for (int j = 0; j <= n * (n - 1) / 2; ++j)
        if (f[i][j] != 0x3f3f3f3f)
          for (int k = 0; k < count; ++k)
            f[i | (1 << pos[k])][j + inv[k]] = min(
                f[i | (1 << pos[k])][j + inv[k]], g[f[i][j] + 1][pos[k] + 1]);
    }
    int i;
    for (i = 0; i <= n * (n - 1) / 2; ++i)
      if (f[(1 << n) - 1][i] != 0x3f3f3f3f) break;
    if (i < ans) ans = i, id = l;
  }
  if (ans > n * (n - 1) / 2)
    puts("Brand new problem!");
  else {
    printf("%d\n[:", id);
    for (int j = n * (n - 1) / 2 - ans + 1; j; --j) printf("|");
    printf(":]\n");
  }
  return 0;
}
