public void solve() throws IOException {
    int n = nextInt();
    for (int i = 0; i < n; i++) {
      HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
      for (int x = 0; x < 25; x++) {
        if (x != 12) {
          map.put(nextInt(), x);
        }
      }

      boolean[][] board = new boolean[5][5];
      board[2][2] = true;

      int num = -1;
      for (int x = 0; x < 75; x++) {
        Integer index = map.get(nextInt());
        if (num == -1 && index != null) {
          board[index / 5][index % 5] = true;
          if (isBingo(board)) {
            num = x + 1;
          }
        }
      }
      System.out.format("BINGO after %d numbers announced\n", num);
    }
  }