#include using namespace std; int main(){ int n; cin>>n; vectorp(n),q(n); for(auto&e:p)cin>>e,--e; for(auto&e:q)cin>>e,--e; vectoriq(n); for(int i=0;iq[i+1]; int ans=0; while(1<