added code for Uva:146