#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
vector<string> pr;
vector<vector<string> > ar;
int bcnt(int m) {
  int ans = 0;
  for (int i = 0; i < 25; i++)
    if (m & (1 << i)) ans++;
  return ans;
}
int main() {
  ;
  int n = 0, m = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s, pr.push_back(s), mp[s] = i;
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int k = 0;
    scanf("%d", &k);
    vector<string> v;
    for (int j = 0; j < k; j++) {
      string s;
      cin >> s;
      v.push_back(s);
    }
    ar.push_back(v);
  }
  pair<int, int> ans;
  ans.first = ans.second = -1;
  sort(pr.begin(), pr.end());
  do {
    int x = 0;
    for (int i = 0; i < (int)pr.size(); i++)
      for (int j = i + 1; j < (int)pr.size(); j++)
        if (i > j != mp[pr[i]] > mp[pr[j]]) x++;
    for (int i = 0; i < m; i++) {
      int k = (int)ar[i].size();
      int ind = 0;
      bool good = false;
      for (int j = 0; j < k; j++)
        if (pr[ind] == ar[i][j]) {
          ind++;
          if (ind == n) {
            good = true;
            break;
          }
        }
      if (good) {
        int p = (n * (n - 1) / 2) - x + 1;
        if (p > ans.first || (p == ans.first && i < ans.second))
          ans.first = p, ans.second = i;
      }
    }
  } while (next_permutation(pr.begin(), pr.end()));
  if (ans.first == -1)
    puts("Brand new problem!");
  else {
    printf("%d\n[:", ans.second + 1);
    for (int i = 0; i < ans.first; i++) printf("|");
    printf(":]\n");
  };
  return 0;
}
