#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class MovingRooksDiv1 { public:
vector <int> move(vector <int> Y1, vector <int> Y2)
{
const int N = Y1.size();
vector<int> ans;
for(int i=0; i<N; ++i)
{
if(Y1[i] < Y2[i])
return vector<int>(1, -1);
else if(Y1[i] > Y2[i])
{
vector<int> idx;
idx.push_back(i);
for(int k=i+1;; ++k)
{
if(Y1[idx.back()] > Y1[k])
idx.push_back(k);
if(Y1[k] == Y2[i])
break;
}
for(int k=idx.size()-2; k>=0; --k) {
ans.push_back(idx[k]);
ans.push_back(idx[k+1]);
swap(Y1[idx[k]], Y1[idx[k+1]]);
}
}
}
if(ans.size() > 2500)
ans.resize(2500);
return ans;
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector <int>& Expected, const vector <int>& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, MovingRooksDiv1().move(Y1, Y2));}
int main(){
CASE(0)
int Y1_[] = {0};
vector <int> Y1(Y1_, Y1_+sizeof(Y1_)/sizeof(*Y1_));
int Y2_[] = {0};
vector <int> Y2(Y2_, Y2_+sizeof(Y2_)/sizeof(*Y2_));
vector <int> _;
END
CASE(1)
int Y1_[] = {1,0};
vector <int> Y1(Y1_, Y1_+sizeof(Y1_)/sizeof(*Y1_));
int Y2_[] = {0,1};
vector <int> Y2(Y2_, Y2_+sizeof(Y2_)/sizeof(*Y2_));
int __[] = {0, 1 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(2)
int Y1_[] = {1,2,0};
vector <int> Y1(Y1_, Y1_+sizeof(Y1_)/sizeof(*Y1_));
int Y2_[] = {2,0,1};
vector <int> Y2(Y2_, Y2_+sizeof(Y2_)/sizeof(*Y2_));
int __[] = {-1 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(3)
int Y1_[] = {2,1,0,3,5,4};
vector <int> Y1(Y1_, Y1_+sizeof(Y1_)/sizeof(*Y1_));
int Y2_[] = {0,1,2,3,4,5};
vector <int> Y2(Y2_, Y2_+sizeof(Y2_)/sizeof(*Y2_));
int __[] = {0, 1, 0, 2, 1, 2, 4, 5 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(4)
int Y1_[] = {10,9,8,7,6,5,4,3,2,1,0};
vector <int> Y1(Y1_, Y1_+sizeof(Y1_)/sizeof(*Y1_));
int Y2_[] = {0,1,2,3,4,5,6,7,8,9,10};
vector <int> Y2(Y2_, Y2_+sizeof(Y2_)/sizeof(*Y2_));
int __[] = {0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3, 10, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4, 10, 5, 6, 5, 7, 5, 8, 5, 9, 5, 10, 6, 7, 6, 8, 6, 9, 6, 10, 7, 8, 7, 9, 7, 10, 8, 9, 8, 10, 9, 10 };
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
CASE(5)
int Y1_[] = {2,1,0};
vector <int> Y1(Y1_, Y1_+sizeof(Y1_)/sizeof(*Y1_));
int Y2_[] = {0,2,1};
vector <int> Y2(Y2_, Y2_+sizeof(Y2_)/sizeof(*Y2_));
int __[] = {123456789};
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
/*
CASE(6)
int Y1_[] = ;
vector <int> Y1(Y1_, Y1_+sizeof(Y1_)/sizeof(*Y1_));
int Y2_[] = ;
vector <int> Y2(Y2_, Y2_+sizeof(Y2_)/sizeof(*Y2_));
int __[] = ;
vector <int> _(__, __+sizeof(__)/sizeof(*__));
END
*/
}
// END CUT HERE