added code for Uva:865