uva 10047
 merge