Fix input check and separate from IO
Solve