#include using namespace std; vector> bubble_sort(vectorA){ vector> ret; int N=size(A); for(int i=0;iA[j+1]){ swap(A[j],A[j+1]); ret.emplace_back(j,j+1); } } return ret; } int main(){ int N,K;cin>>N>>K; vector P(N); for(auto&p:P)cin>>p; vector> ans; for(int i=0;i Q; for(int j=i;j> op=bubble_sort(Q); for(auto&[a,b]:op)ans.emplace_back(a*K+i,b*K+i); } vector sorted_P=P; ranges::sort(sorted_P); for(auto[a,b]:ans) swap(P[a],P[b]); if(P!=sorted_P){ cout<<-1<