#include #pragma region my_template struct Rep { struct I { int i; void operator++() { ++i; } int operator*() const { return i; } bool operator!=(I o) const { return i < *o; } }; const int l_, r_; Rep(int l, int r) : l_(l), r_(r) {} Rep(int n) : Rep(0, n) {} I begin() const { return {l_}; } I end() const { return {r_}; } }; struct Per { struct I { int i; void operator++() { --i; } int operator*() const { return i; } bool operator!=(I o) const { return i > *o; } }; const int l_, r_; Per(int l, int r) : l_(l), r_(r) {} Per(int n) : Per(0, n) {} I begin() const { return {r_ - 1}; } I end() const { return {l_ - 1}; } }; template struct Fix : private F { Fix(F f) : F(f) {} template decltype(auto) operator()(Args&&... args) const { return F::operator()(*this, std::forward(args)...); } }; template T scan() { T res; std::cin >> res; return res; } template bool chmin(T& a, U&& b) { return b < a ? a = std::forward(b), true : false; } template bool chmax(T& a, U&& b) { return a < b ? a = std::forward(b), true : false; } #ifndef LOCAL #define DUMP(...) void(0) template constexpr int OjLocal = OnlineJudge; #endif using namespace std; #define ALL(c) begin(c), end(c) #pragma endregion int main() { cin.tie(nullptr)->sync_with_stdio(false); cout << fixed << setprecision(20); int n = scan(); auto s = scan(); auto t = scan(); vector a(n), b(n); for (int i : Rep(n)) { a[i] = 2 * (s[i] & 1) + (s[n + i] & 1); b[i] = 2 * (t[i] & 1) + (t[n + i] & 1); if ((a[i] == 0) ^ (b[i] == 0)) { cout << "-1\n"; exit(0); } } vector ans; bool rev = false; auto go = [&](int x) { ans.push_back(x); rev ^= true; if (x < n) { for (int i : Rep(n)) if (i < x and a[i] & 2) a[i] ^= 1; else if (i >= x and a[i] & 1) a[i] ^= 2; } else if (x == n) { x -= n; for (int i : Rep(n)) if (i < x and a[i] & 1) a[i] ^= 2; else if (i >= x and a[i] & 2) a[i] ^= 1; } else assert(false); }; for (int i : Rep(n)) { if (b[i] == 1) { if (a[i] == 2) go(n); if (a[i] == 3) go(i); } else if (a[i] == 1) { go(i); if ((b[i] == 3) ^ rev) go(n); } assert((a[i] == 1) == (b[i] == 1)); } DUMP(a); DUMP(b); cout << size(ans) << '\n'; for (auto&& e : ans) cout << e << '\n'; }