solution for uva 1368