Man hit by train loses both legs