#include <bits/stdc++.h>
using namespace std;
vector<pair<string, int> > prob, temp;
vector<string> now;
bool isSub() {
  int prev = -1;
  for (int i = 0; i < temp.size(); i++) {
    int j;
    bool found = false;
    for (j = prev + 1; j < now.size(); j++) {
      if (temp[i].first == now[j]) {
        found = true;
        prev = j;
        break;
      }
    }
    if (!found) return false;
  }
  return true;
}
int countInv() {
  int cnt = 0;
  for (int i = 0; i < temp.size(); i++) {
    for (int j = i + 1; j < temp.size(); j++) {
      if (temp[j].second < temp[i].second) cnt++;
    }
  }
  return cnt;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    prob.push_back(make_pair(x, i));
  }
  int m;
  scanf("%d", &m);
  int sim = 0, simidx = -1;
  for (int i = 0; i < m; i++) {
    int k;
    scanf("%d", &k);
    now.clear();
    for (int j = 0; j < k; j++) {
      string x;
      cin >> x;
      now.push_back(x);
    }
    int ginv = INT_MAX;
    temp = prob;
    sort(temp.begin(), temp.end());
    do {
      if (isSub()) {
        int inv = countInv();
        if (inv < ginv) {
          ginv = inv;
          if (n * (n - 1) / 2 - inv + 1 > sim) {
            sim = n * (n - 1) / 2 - inv + 1;
            simidx = i;
          }
        }
      }
    } while (next_permutation(temp.begin(), temp.end()));
  }
  if (simidx == -1)
    puts("Brand new problem!");
  else {
    cout << simidx + 1 << endl;
    printf("[:");
    for (int i = 0; i < sim; i++) printf("|");
    printf(":]");
    puts("");
  }
  return 0;
}
