you give positive integer m integer sequence aa_1 a_2 ldot a_n bb_1 b_2 ldot b_n both sequence length nPermutation sequence n different positive integer 1 n for example sequence permutation 1 12 21 6734125 these 0 11 23you need find nonnegative integer x increase element a_i x modulo m ie want change a_i a_i x bmod m possible rearrange element equal b need find small possible xIn word need find small nonnegative integer x possible find permutation pp_1 p_2 ldot p_n 1 leq leq n a_i x bmod m b_p_i y bmod m remainder division y mFor example m3 0 0 2 1 b 2 0 1 1 choose x1 equal 1 1 0 2 rearrange equal 2 0 1 1 equal b