#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
int n, m, k;
string wrote[20];
string arc[500005];
int nxt[20][500005];
int dp[1 << 15][300];
int func() {
  for (int i = 0; i < n; ++i) {
    nxt[i][k] = k;
    int last = k;
    for (int j = k - 1; j >= 0; --j) {
      if (arc[j] == wrote[i]) last = j;
      nxt[i][j] = last;
    }
  }
  int maxi = n * (n - 1);
  for (int i = 0; i < 1 << n; ++i)
    for (int j = 0; j < maxi + 1; ++j) dp[i][j] = INF;
  dp[0][0] = 0;
  int tmp[20];
  for (int i = 0; i < 1 << n; ++i)
    for (int j = 0; j < maxi + 1; ++j)
      if (dp[i][j] < k) {
        tmp[n] = 0;
        for (int i2 = n - 1; i2 >= 0; --i2) {
          tmp[i2] = tmp[i2 + 1] + (i >> i2 & 1);
        }
        for (int i2 = 0; i2 < n; ++i2)
          if (!(i >> i2 & 1)) {
            dp[i | (1 << i2)][j + tmp[i2]] =
                min(dp[i | (1 << i2)][j + tmp[i2]], nxt[i2][dp[i][j]] + 1);
          }
      }
  int mininv = INF;
  for (int i = 0; i < maxi + 1; ++i)
    if (dp[(1 << n) - 1][i] <= k) {
      mininv = i;
      break;
    }
  return n * (n - 1) / 2 - mininv + 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) cin >> wrote[i];
  scanf("%d", &m);
  int res = -1, who;
  for (int i = 0; i < m; ++i) {
    scanf("%d", &k);
    for (int j = 0; j < k; ++j) cin >> arc[j];
    int ans = func();
    if (res < ans) {
      res = ans;
      who = i;
    }
  }
  if (res == -1)
    puts("Brand new problem!");
  else {
    printf("%d\n", who + 1);
    printf("[:");
    for (int i = 0; i < res; ++i) putchar('|');
    printf(":]\n");
  }
  return 0;
}
