solve RUPC2013 A