solution for uva 1388