In the first test, Sasha has 2 classes, which will take a total of $90+90 = 180 $ minutes, after which he will spend another $1+2 = 3$ minutes on homework, so he will have exactly $26$ hours and $57$ minutes left out of 30 hours.

In the second test, Sasha has 3 classes, which will take a total of $270$ minutes, and he will spend another $60+60+60=180$ minutes on homework, so he will have only $22$ hours and $30$ minutes left for sleep.