added code for Uva:492