#include #include #include using namespace std; using ll = long long; void Print(vector>& ans){ int n=ans.size(), m=ans[0].size(); for(int i=0; i> n; vector a(n), b(n), pos(n); for(auto&x:a) cin >> x, x--; for(int i=0; i> b[i], b[i]--, pos[b[i]]=i; vector ans(n+1, vector(n)); for(int i=0; imax(abs(nd1), abs(nd2))){ swap(ans[t+1][j], ans[t+1][j+1]); j++; } } } //Print(ans); if(ans[n]==b) Print(ans); else cout << -1 << endl; return 0; }