you give permutation p q consist n element m query form l1r1l2r2 l1r1l2r2 the response query number integer 1 n position permutation segment l1r1 border include position second permutation segment l2r2 border include tooa permutation n element sequence n distinct integer 1 great nPosition number v 1vn permutation g1g2gn number giv