#include <bits/stdc++.h>
using namespace std;
const int MAXN = 8;
const int MAXM = 32;
const int INF = 1012345678;
int n, m, q;
bool dp[MAXN][MAXM];
map<string, int> wordMap;
int calc() {
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    a[i] = i;
  }
  scanf("%d", &m);
  vector<int> b;
  for (int i = 0; i < m; i++) {
    char token[16];
    scanf("%s", token);
    if (wordMap.find(token) != wordMap.end()) {
      b.push_back(wordMap[token]);
    }
  }
  m = b.size();
  int res = INF;
  do {
    dp[0][0] = true;
    int prev = 0;
    bool found = true;
    for (int i = 0; i < n && found; i++) {
      for (int j = prev; j <= m; j++) {
        if (j == m) {
          found = false;
          break;
        }
        if (a[i] == b[j]) {
          prev = j + 1;
          break;
        }
      }
    }
    if (found) {
      int tmpres = 0;
      for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
          tmpres += a[i] > a[j];
        }
      }
      res = min(res, tmpres);
    }
  } while (next_permutation(a.begin(), a.end()));
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char token[128];
    scanf("%s", token);
    wordMap[token] = i;
  }
  scanf("%d", &q);
  int p = INF, res = -1;
  for (int i = 0; i < q; i++) {
    int tmp = calc();
    if (p > tmp) {
      p = tmp;
      res = i;
    }
  }
  if (res == -1) {
    puts("Brand new problem!");
  } else {
    printf("%d\n[:", res + 1);
    for (int i = n * (n - 1) / 2 - p + 1; i > 0; i--) putchar('|');
    puts(":]");
  }
  return 0;
}
