added code for Uva:371