#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
const int MAXM = 100;
const int MAXL = 100;
const int INF = 10000000;
vector<int> idx;
int n, m;
char str[MAXN + 1][MAXL + 1];
char s[MAXN + 1][MAXM + 1][MAXL + 1];
int t[MAXM + 1];
void InputData() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    idx.push_back(i);
    scanf("%s", str[i]);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &t[i]);
    for (int j = 0; j < t[i]; j++) {
      scanf("%s", s[i][j]);
    }
  }
}
void OutputData() {
  int res = -1;
  int ID = INF;
  do {
    int ret = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (idx[i] > idx[j]) ret++;
      }
    }
    for (int i = 0; i < m; i++) {
      int st = 0;
      for (int j = 0; j < t[i]; j++) {
        if (strcmp(str[idx[st]], s[i][j]) == 0) {
          st++;
          if (st == n) break;
        }
      }
      if (st == n) {
        if (res < n * (n - 1) / 2 - ret + 1 ||
            (res == n * (n - 1) / 2 - ret + 1 && ID > i)) {
          res = n * (n - 1) / 2 - ret + 1;
          ID = i;
        }
      }
    }
  } while (next_permutation(idx.begin(), idx.end()));
  if (res == -1) {
    puts("Brand new problem!\n");
  } else {
    printf("%d\n", ID + 1);
    printf("[:");
    for (int i = 0; i < res; i++) printf("|");
    printf(":]\n");
  }
}
int main() {
  InputData();
  OutputData();
  return 0;
}
