def get_rails(string: str, n: int) -> list:
    """
    Create rails matrix.

    :param string: a string
    :param n: the number of rails
    :return: rails matrix
    """

    rails: list = list()
    while len(rails) != n:
        rails.append(list())

    row = 0
    down = True
    for char in string:

        for char_index in range(0, n):
            if char_index != row:
                rails[char_index].append("")
            else:
                rails[char_index].append(char)

        if row == n - 1 and down:
            down = False

        if row == 0 and not down:
            down = True

        if down:
            row += 1
        else:
            row -= 1

    return rails