#include <bits/stdc++.h>
#pragma warning(disable : 4786)
using namespace std;
string itos(int i) {
  stringstream s;
  s << i;
  return s.str();
}
vector<string> Tokenize(string s, string ch) {
  vector<string> ret;
  for (int p = 0, p2; p < s.size(); p = p2 + 1) {
    p2 = (int)s.find_first_of(ch, p);
    if (p2 == -1) p2 = (int)s.size();
    if (p2 - p > 0) ret.push_back(s.substr(p, p2 - p));
  }
  return ret;
}
vector<int> TokenizeInt(string s, string ch) {
  vector<int> ret;
  vector<string> p = Tokenize(s, ch);
  for (int i = 0; i < p.size(); i++) ret.push_back(atoi(p[i].c_str()));
  return ret;
}
vector<vector<int> > TokenizeMatrix(vector<string> s, string ch) {
  vector<vector<int> > ret;
  for (int i = 0; i < s.size(); i++) ret.push_back(TokenizeInt(s[i], ch));
  return ret;
}
int parseInts(char buff[], int a[]) {
  int n = 0;
  char *p = strtok(buff, " ");
  while (p != NULL) {
    sscanf(p, "%d", &a[n++]);
    p = strtok(NULL, " ");
  }
  return n;
}
int getInt(void) {
  int d;
  scanf("%d", &d);
  return d;
}
double getDouble(void) {
  double d;
  scanf("%lf", &d);
  return d;
}
bool DBG = true;
vector<string> pr;
vector<string> ar[50];
int main(void) {
  pr.clear();
  int n = getInt();
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    pr.push_back(s);
  }
  int nar = getInt();
  for (int j = 0; j < nar; ++j) {
    int k = getInt();
    ar[j].clear();
    for (int i = 0; i < k; ++i) {
      string s;
      cin >> s;
      ar[j].push_back(s);
    }
  }
  bool found = false;
  int resInd, resP = 10000000;
  for (int ind = 0; ind < nar; ++ind) {
    vector<int> v;
    v.clear();
    for (int i = 0; i < n; ++i) {
      v.push_back(i);
    }
    do {
      int inv = 0;
      for (int i = 0; i < v.size(); ++i) {
        for (int j = i + 1; j < v.size(); ++j) {
          if (v[j] < v[i]) inv++;
        }
      }
      int i1 = 0;
      int i2 = 0;
      while (i1 < v.size() && i2 < ar[ind].size()) {
        if (pr[v[i1]] == ar[ind][i2]) {
          i1++;
          i2++;
        } else {
          i2++;
        }
      }
      if (i1 >= v.size()) {
        found = true;
        int p = inv;
        if (p < resP) {
          resP = p;
          resInd = ind;
        }
      }
    } while (next_permutation(v.begin(), v.end()));
  }
  if (!found) {
    printf("Brand new problem!\n");
  } else {
    printf("%d\n", resInd + 1);
    printf("[:");
    resP = (n * (n - 1)) / 2 - resP + 1;
    for (int l = 0; l < resP; ++l) printf("|");
    printf(":]");
    printf("\n");
  }
  return 0;
}
