#include #define fi first #define se second #define rep(i,s,n) for (int i = (s); i < (n); ++i) #define rrep(i,g,n) for (int i = (n)-1; i >= (g); --i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define len(x) (int)(x).size() #define dup(x,y) (((x)+(y)-1)/(y)) #define pb push_back #define eb emplace_back #define Field(T) vector> using namespace std; using ll = long long; using ull = unsigned long long; template using pq = priority_queue,greater>; using P = pair; templatebool chmax(T&a,T b){if(abool chmin(T&a,T b){if(b> n >> k; vector p(n); rep(i,0,n) cin >> p[i]; vector

ans; rep(t,0,n) rep(i,0,n-k) { if (p[i] > p[i+k]) ans.eb(i, i+k), swap(p[i], p[i+k]); } rep(i,0,n) { if (p[i] != i+1) { cout << -1 << endl; return 0; } } cout << len(ans) << endl; for (auto [i, j] : ans) cout << i+1 << " " << j+1 << endl; return 0; }