#include<bits/stdc++.h> // #define SINGLE_INPUT #define ll long long #define ull unsigned long long #define N 500005 #define MOD 998244353 usingnamespace std;
template<classt,classu> ostream& operator<<(ostream& os,const pair<t,u>& p) { return os<<'['<<p.first<<", "<<p.second<<']'; } template<classt> ostream& operator<<(ostream& os,const vector<t>& v) { os<<'['; int s = 1; for(auto e:v) { if (s) s = 0; else os << ", "; os << e; } return os<<']'; } template<classt,classu> ostream& operator<<(ostream& os,const map<t,u>& mp){ os<<'{'; int s = 1; for(auto [x,y]:mp) { if (s) s = 0; else os << ", "; os<<x<<": "<<y; } return os<<'}'; }
voidsol(){ int n; cin >> n; vector<int> b(n+1), p(n+1), s(n+1, -1); for (int i=1; i<=n; i++) { cin >> b[i]; if (i == b[i]); } for (int i=1; i<=n; i++) { int x; cin >> x; s[x] = i; } // cout << b << endl; // cout << s << endl; int ok = 1; for (int i=1; i<=n; i++) { if (s[i] < s[b[i]]) ok = 0; } if (ok) { for (int i=1; i<=n; i++) { cout << s[i] - s[b[i]] << " "; } cout << "\n"; } else { cout << "-1\n"; }