#include <bits/stdc++.h>
using namespace std;
int n, m;
char temp[30];
string str[10];
vector<string> ivan[20];
int arr[10];
int inversion() {
  int ret = 0;
  for (int(i) = (0), _n = (n - 1); (i) <= _n; (i)++) {
    for (int(j) = (i + 1), _n = (n - 1); (j) <= _n; (j)++) {
      if (arr[i] > arr[j]) ret++;
    }
  }
  return ret;
}
bool isSubsequence(int ind) {
  int pos = 0;
  for (int(i) = (0), _n = (ivan[ind].size() - 1); (i) <= _n; (i)++) {
    if (pos >= n) break;
    if (str[arr[pos]] == ivan[ind][i]) pos++;
  }
  return pos >= n;
}
int main() {
  scanf("%d", &n);
  for (int(i) = (0), _n = (n - 1); (i) <= _n; (i)++) {
    scanf("%s", temp);
    str[i] = temp;
  }
  scanf("%d", &m);
  for (int(i) = (0), _n = (m - 1); (i) <= _n; (i)++) {
    int x;
    scanf("%d", &x);
    while (x--) {
      scanf("%s", temp);
      ivan[i].push_back(temp);
    }
  }
  int ans = 200000000, ans2 = -1;
  for (int(ind) = (0), _n = (m - 1); (ind) <= _n; (ind)++) {
    for (int(i) = (0), _n = (n - 1); (i) <= _n; (i)++) arr[i] = i;
    int cnt = 200000000;
    bool _b = false;
    do {
      if (isSubsequence(ind)) cnt = min(inversion(), cnt);
    } while (next_permutation(arr, arr + n));
    if (cnt != 200000000) {
      if (ans > cnt) {
        ans = cnt;
        ans2 = ind;
      }
    }
  }
  if (ans2 == -1)
    puts("Brand new problem!");
  else {
    printf("%d\n", ans2 + 1);
    ans = n * (n - 1) / 2 - ans + 1;
    printf("[:");
    for (int(i) = (1), _n = (ans); (i) <= _n; (i)++) printf("|");
    puts(":]");
  }
  for (int(i) = (1), _n = (2); (i) <= _n; (i)++) getchar();
  return 0;
}
