#include <bits/stdc++.h>
using namespace std;
inline void gtmx(int& a, int b) {
  if (a < b) a = b;
}
inline void gtmn(int& a, int b) {
  if (a > b) a = b;
}
struct trie {
  int id;
  trie* nxt[27];
  void clear() {
    id = -1;
    memset(nxt, 0, sizeof(nxt));
  }
  trie* insert(char c) {
    if (nxt[c] == NULL) {
      nxt[c] = new (trie);
      nxt[c]->clear();
    }
    return nxt[c];
  }
};
int tmp[18];
int nct[500010][18], lst[500010][18];
int init[500010];
int dp[32777][111];
int lt[18], rt[18];
int main(void) {
  int n, m;
  scanf("%d", &n);
  trie* rot = new (trie);
  rot->clear();
  char c = getchar();
  for (int i = 0; i < n; ++i) {
    while (c == 10 || c == 32) {
      c = getchar();
    }
    trie* cur = rot;
    while (c != 10 && c != 32) cur = cur->insert(c - 'a'), c = getchar();
    cur->id = i;
  }
  int res = 100000, reid = -1;
  int mxinv = n * (n - 1) / 2;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int l, cnt = 0;
    scanf("%d", &l);
    c = getchar();
    for (int j = 1; j <= l; ++j) {
      trie* cur = rot;
      while (c == 10 || c == 32) c = getchar();
      while (c != 10 && c != 32) {
        if (cur->nxt[c - 'a']) {
          cur = cur->nxt[c - 'a'];
        } else {
          break;
        }
        c = getchar();
      }
      if (c != 10 && c != 32) {
        while (c != 10 && c != 32) c = getchar();
        continue;
      }
      if (~cur->id) {
        ++cnt;
        init[cnt] = cur->id;
      }
    }
    if (n == 1 && cnt) {
      printf("%d\n[:|:]", i);
      return 0;
    }
    if (n == 1) continue;
    memset(tmp, 255, sizeof(tmp));
    for (int ii = cnt; ii; --ii) {
      tmp[init[ii]] = ii;
      memcpy(nct[ii], tmp, sizeof(tmp));
    }
    memset(tmp, 255, sizeof(tmp));
    for (int ii = 1; ii <= cnt; ++ii) {
      tmp[init[ii]] = ii;
      memcpy(lst[ii], tmp, sizeof(tmp));
    }
    memset(dp, 63, sizeof(dp));
    dp[0][0] = 1;
    for (int st = 0; st < (1 << n); ++st) {
      for (int j = 0; j <= mxinv; ++j) {
        if (dp[st][j] > cnt) continue;
        int tc = 0;
        for (int k = n - 1; ~k; --k) {
          if (st & (1 << k)) {
            ++tc;
            continue;
          }
          if (nct[dp[st][j]][k] == -1) continue;
          gtmn(dp[st | (1 << k)][j + tc], nct[dp[st][j]][k]);
        }
      }
    }
    for (int j = 0; j <= mxinv; ++j) {
      if (res > j && dp[(1 << n) - 1][j] <= cnt) {
        res = j;
        reid = i;
      }
    }
  }
  if (res < 1000 && ~reid) {
    res = n * (n - 1) / 2 - res + 1;
    printf("%d\n[:", reid);
    while (res--) putchar('|');
    printf(":]");
  } else {
    printf("Brand new problem!");
  }
  return 0;
}
