from typing import Tuple
from typing import List


def parse_input(raw_input: str) -> Tuple[
  List[int], List[List[List[int]]], List[List[List[bool]]]]:
  """Parses puzzle input and returns game state.

  - ``draws`` is a list of ints, read from input.
  - ``boards`` is a list of boards, read from input. each board is a
    two-dimensional list of ints.
  - ``marks`` is a list of marks, of the same length as ``boards``. each mark is
    a two-dimensional list of booleans, initially ``False``.

  :param raw_input: a string containing the puzzle input
  :return: game state, a tuple of (draws, boards, marks)
  """
  draws = []
  boards = []
  marks = []

  current_board = []

  def finish_board():
    nonlocal boards, current_board, marks
    if len(current_board):
      boards.append(current_board)
      ii, jj = len(current_board), len(current_board[0])
      marks.append([[False for _ in range(jj)]
                    for _ in range(ii)])
      current_board = []

  for i, line in enumerate(raw_input.strip().splitlines()):
    if i == 0:
      draws = [int(i) for i in line.split(',')]
      continue

    if line == '':
      finish_board()
      continue

    current_board.append([int(i) for i in line.split()])
  else:
    finish_board()

  return draws, boards, marks