#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[30][30], now[30][30];
map<string, int> lesha, prob;
vector<int> word[20];
int out[20];
int process(int ind, int count);
int find();
int mini(int a, int b) {
  if (a < b) return a;
  return b;
}
int main() {
  int i, j, k, l, test, t = 1;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%s", s[i]);
    lesha[s[i]] = i;
  }
  int flag = 0;
  scanf("%d", &m);
  int i1, ans = 0, ans1 = 100000, val;
  for (i1 = 1; i1 <= m; i1++) {
    scanf("%d", &k);
    for (i = 1; i <= n; i++) {
      word[i].clear();
    }
    for (j = 1; j <= k; j++) {
      scanf("%s", now[j]);
      if (lesha[now[j]] == 0)
        continue;
      else {
        l = lesha[now[j]];
        word[l].push_back(j);
      }
    }
    flag = 1;
    for (i = 1; i <= n; i++) {
      if (word[i].size() == 0) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      val = process(1, 0);
      if (val < ans1) {
        ans = i1;
        ans1 = val;
      }
    }
  }
  if (ans == 0) {
    printf("Brand new problem!\n");
    return 0;
  }
  k = n * (n - 1);
  k /= 2;
  k++;
  k -= ans1;
  printf("%d\n", ans);
  printf("[:");
  for (i = 1; i <= k; i++) {
    printf("|");
  }
  printf(":]\n");
  return 0;
}
int find() {
  int i, j, k, l, ret = 0;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (out[j] < out[i]) ret++;
    }
  }
  return ret;
}
int process(int ind, int count) {
  if (count == n) {
    return find();
  }
  int ret = 10000, i, j, k, l;
  for (i = 0; i < word[ind].size(); i++) {
    k = word[ind][i];
    out[count] = k;
    ret = mini(ret, process(ind + 1, count + 1));
  }
  return ret;
}
