#include <bits/stdc++.h>
using namespace std;
string s[4 + 10], s2[20 + 5], s3, s4;
int n, m, k;
int num_inv(string a) {
  int count1 = 0;
  for (int i = 1; i < a.size(); i++)
    for (int j = i - 1; j >= 0; j--)
      if (a[j] > a[i]) count1++;
  return count1;
}
int ans, ans1;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    s3 += ('0' + i);
  }
  cin >> m;
  s4 = s3;
  for (int i = 0; i < m; i++) {
    cin >> k;
    s3 = s4;
    for (int j = 0; j < k; j++) cin >> s2[j];
    do {
      int w = 0;
      for (int j = 0; j < k; j++) {
        if (w < n && s2[j] == s[s3[w] - '0']) w++;
      }
      if (w == n) {
        int x = num_inv(s3);
        int p = (n * (n - 1)) / 2 - x + 1;
        if (p > ans) {
          ans = p;
          ans1 = i + 1;
        }
      }
    } while (next_permutation(s3.begin(), s3.end()));
  }
  if (ans == 0) return cout << "Brand new problem!", 0;
  cout << ans1 << endl;
  cout << "[:";
  for (int i = 0; i < ans; i++) cout << '|';
  cout << ":]";
}
