#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T Max(T a, T b) {
  if (a > b)
    return a;
  else
    return b;
}
template <class T>
inline T Min(T a, T b) {
  if (a < b)
    return a;
  else
    return b;
}
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline T TripleMax(T a, T b, T c) {
  return Max(Max(a, b), c);
}
template <class T>
inline T TripleMin(T a, T b, T c) {
  return Min(Min(a, b), c);
}
const long double pi = M_PI;
const long double e = M_E;
const long double sqrt2 = M_SQRT2;
string s[4];
int data[4];
int n;
int sid, num;
int ret;
int judge;
string w[25];
int bestp, bestindex;
int check(int i, int j) {
  if (i < 0) {
    return 1;
  }
  if (j < 0) {
    return 0;
  }
  for (int d = j; d >= 0; d--) {
    if (w[d] == s[data[i] - 1]) {
      if (check(i - 1, d - 1) == 1) {
        return 1;
      } else {
        return 0;
      }
    }
  }
  return 0;
}
int get() {
  int ret = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i - 1; j >= 0; j--) {
      if (data[j] > data[i]) {
        ret++;
      }
    }
  }
  return ret;
}
int main(int argc, const char* argv[]) {
  bestp = 100;
  bestindex = 100;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    data[i] = i + 1;
  }
  cin >> sid;
  for (int i = 0; i < sid; i++) {
    cin >> num;
    for (int j = 0; j < num; j++) {
      cin >> w[j];
    }
    sort(data, data + n);
    ret = 1 << 10;
    judge = 0;
    do {
      if (check(n - 1, num - 1) == 1) {
        judge = 1;
        ret = Min(get(), ret);
      }
    } while (next_permutation(data, data + n));
    if (judge == 1) {
      if (ret < bestp) {
        bestindex = i + 1;
        bestp = ret;
      }
    }
  }
  if (bestp != 100 || bestindex != 100) {
    cout << bestindex << endl;
    cout << "[:" << string((n * (n - 1) / 2) - bestp + 1, '|') << ":]" << endl;
    return 0;
  }
  cout << "Brand new problem!" << endl;
  return 0;
}
