def grid_to_ciphertext(grid: list[list[str]]) -> str:
    """Return the ciphertext corresponding to the given grid.

    Preconditions:
        - grid != []
        - grid[0] != []
        - all({len(row1) == len(row2) for row1 in grid for row2 in grid})
    """
    # zip transposes an array: list(zip([1, 2], [3, 4], [5, 6])) = [(1, 3, 5), (2, 4, 6)]
    # return ''.join([s for row in zip(*grid) for s in row])
    # But since we didn't learn zip:
    return ''.join(''.join(grid[j][i] for j in range(len(grid))) for i in range(len(grid[0])))