Loop to find all the valid operations required to sort the permutation
for ( ll i = 0 ; i < p . size ( ) ; i += 4 ) { ans . push_back ( make_pair ( p [ i ] , make_pair ( p [ i + 1 ] , p [ i + 2 ] ) ) ) ; ans . push_back ( make_pair ( p [ i + 2 ] , make_pair ( p [ i ] , p [ i + 3 ] ) ) ) ; }