#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
string s[100];
string read[100];
int len[100];
string words[100][100];
int n;
int subs(int pos) {
  if (n > len[pos]) return 0;
  int j = 0;
  for (int i = (0); i < (int)(n); i++) {
    while (j < len[pos] && words[pos][j] != s[i]) j++;
    if (j == len[pos]) {
      return 0;
    } else {
      j++;
    }
  }
  return 1;
}
int perm[100];
int main() {
  cin >> n;
  for (int i = (0); i < (int)(n); i++) {
    cin >> read[i];
  }
  int m;
  cin >> m;
  for (int i = (0); i < (int)(m); i++) {
    cin >> len[i];
    for (int j = (0); j < (int)(len[i]); j++) {
      cin >> words[i][j];
    }
  }
  int found = false;
  for (int i = (0); i < (int)(n); i++) {
    perm[i] = i + 1;
  }
  string aux;
  int ans = -1;
  int val = -1;
  for (int i = (0); i < (int)(m); i++) {
    do {
      for (int j = (0); j < (int)(n); j++) {
        s[j] = read[perm[j] - 1];
      }
      if (subs(i)) {
        int p = 0;
        int x = 0;
        for (int j = (0); j < (int)(n); j++) {
          for (int k = j + 1; k < n; k++) {
            if (perm[k] < perm[j]) x++;
          }
        }
        p = n * (n - 1) / 2 - x + 1;
        if (p > val) {
          ans = i;
          val = p;
        }
      }
    } while (next_permutation(perm, perm + n));
  }
  if (ans == -1) {
    cout << "Brand new problem!\n";
  } else {
    cout << ans + 1 << endl;
    cout << "[:";
    for (int i = (0); i < (int)(val); i++) {
      cout << "|";
    }
    cout << ":]" << endl;
  }
  return 0;
}
