def read_file(filename):
    """
    Read input file and save dots and folds.
    :param filename: input file
    :return: list of dots, list of folds
    """
    dots = []
    folds = []
    max_x = 0
    max_y = 0
    with open(filename, 'r', encoding='UTF-8') as file:
        for line in file:
            if ',' in line:
                x, y = line.strip().split(',')
                x = int(x)
                y = int(y)
                dots.append([x, y])
                max_x = max(max_x, x)
                max_y = max(max_y, y)
            if "=" in line:
                _, _, statement = line.split(" ")
                axis, value = statement.split("=")
                folds.append([axis, int(value.strip())])
    max_x += 1
    max_y += 1
    paper = [[0] * max_x for _ in range(max_y)]
    for x, y in dots:
        paper[y][x] = 1

    return paper, folds