Lab2 final version(debug outputs included)