added code for Uva:495