#include <bits/stdc++.h>
using namespace std;
void loadData(void);
void proc(void);
void printRes(void);
void dfs(int index, int start, int level);
bool containSameElement(void);
int getInverseNum(void);
int n;
vector<string> lsv;
vector<string> v1;
int m;
vector<string> asv[10];
bool tag[21];
vector<string> t_res;
int res_inverse = 1000000000;
int res_index = -1;
bool lyb_debug = true;
int main(int argc, char** argv) {
  loadData();
  proc();
  printRes();
  return 0;
}
int getInverseNum(void) {
  int res = 0;
  int k1, k2;
  for (int i = 0; i < t_res.size(); i++)
    for (int j = i + 1; j < t_res.size(); j++) {
      k1 = find(lsv.begin(), lsv.end(), t_res[i]) - lsv.begin();
      k2 = find(lsv.begin(), lsv.end(), t_res[j]) - lsv.begin();
      if (k1 > k2) {
        res++;
      }
    }
  return res;
}
bool containSameElement(void) {
  vector<string> v2;
  v2.clear();
  for (int i = 0; i < t_res.size(); i++) v2.push_back(t_res[i]);
  sort(v2.begin(), v2.end());
  for (int i = 0; i < v1.size(); i++)
    if (v1[i] != v2[i]) return false;
  return true;
}
void dfs(int index, int start, int level) {
  if (level == n) {
    t_res.clear();
    for (int i = 0; i < asv[index].size(); i++)
      if (tag[i]) {
        t_res.push_back(asv[index][i]);
      }
    if (containSameElement()) {
      int inverseNum = getInverseNum();
      if (inverseNum < res_inverse) {
        res_inverse = inverseNum;
        res_index = index;
      } else if (inverseNum == res_inverse) {
        res_index = min(res_index, index);
      }
    }
    return;
  }
  for (int i = start; i < asv[index].size(); i++) {
    tag[i] = true;
    dfs(index, i + 1, level + 1);
    tag[i] = false;
  }
  return;
}
void proc(void) {
  res_inverse = 1000000000;
  res_index = -1;
  for (int i = 0; i < m; i++) {
    memset(tag, false, sizeof(tag));
    dfs(i, 0, 0);
  }
  return;
}
void loadData(void) {
  char input[11];
  char enter;
  string inputs;
  scanf("%d%c", &n, &enter);
  lsv.clear();
  v1.clear();
  for (int i = 0; i < n; i++) {
    scanf("%s%c", input, &enter);
    inputs = input;
    lsv.push_back(inputs);
    v1.push_back(inputs);
  }
  sort(v1.begin(), v1.end());
  scanf("%d%c", &m, &enter);
  int k;
  for (int i = 0; i < m; i++) {
    scanf("%d%c", &k, &enter);
    asv[i].clear();
    for (int j = 0; j < k; j++) {
      scanf("%s%c", input, &enter);
      inputs = input;
      asv[i].push_back(inputs);
    }
  }
  return;
}
void printRes(void) {
  if (res_index == -1)
    printf("Brand new problem!\n");
  else {
    printf("%d\n", res_index + 1);
    int p = n * (n - 1) / 2 - res_inverse + 1;
    printf("[:");
    for (int i = 0; i < p; i++) printf("|");
    printf(":]\n");
  }
  return;
}
