#include <bits/stdc++.h>
const double eps = 1e-9;
const int int_inf = 1 << 31 - 1;
const long long i64_inf = 1ll << 63 - 1ll;
const double pi = acos(-1.0);
using namespace std;
vector<string> z[20];
pair<string, int> a[10];
int n, m;
int main() {
  scanf("%d\n", &n);
  for (int i = 0; i < (int)n; i++) {
    char c = getchar();
    string cur = "";
    while (c != ' ' && c != '\n') {
      cur += c;
      c = getchar();
    }
    a[i].first = cur;
    a[i].second = i;
  }
  scanf("%d\n", &m);
  for (int i = 0; i < (int)m; i++) {
    int k;
    scanf("%d", &k);
    char c = getchar();
    for (int j = 0; j < (int)k; j++) {
      c = getchar();
      string cur = "";
      while (c != ' ' && c != '\n') {
        cur += c;
        c = getchar();
      }
      z[i].push_back(cur);
    }
  }
  sort(a, a + n);
  int maxp = -1;
  int id = -1;
  do {
    for (int i = 0; i < (int)m; i++) {
      int j = 0;
      for (int ii = 0; ii < (int)z[i].size(); ii++)
        if (z[i][ii] == a[j].first) j++;
      if (j != n) continue;
      int x = 0;
      for (int ii = 0; ii < (int)n; ii++)
        for (int jj = ii + 1; jj < n; jj++) x += (a[jj].second < a[ii].second);
      if (n * (n - 1) / 2 - x + 1 > maxp ||
          n * (n - 1) / 2 - x + 1 == maxp && i < id) {
        maxp = n * (n - 1) / 2 - x + 1;
        id = i;
      }
    }
  } while (next_permutation(a, a + n));
  if (maxp == -1)
    puts("Brand new problem!");
  else {
    printf("%d\n", id + 1);
    printf("[:");
    for (int i = 0; i < (int)maxp; i++) printf("|");
    printf(":]");
  }
  return 0;
}
