#include using namespace std; #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0; i < (n); ++i) typedef long long ll; using P=pair; const int INF=1001001001; const int mod=1e9+7; void solve(){ int n; cin>>n; vectora(n+2),b(n+1); for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) cin>>b[i]; a[0]=-INF;a[n+1]=INF; queue q; int mn=INF,j=-1; for(int i=1;i<=n;i++){ int p=upper_bound(a.begin(),a.end(),b[i])-a.begin(); p--; if(p-i==0){j=i;} } q.push(j); vector>ans; vectorseen(n+1); seen[j]=1; while(!q.empty()){ int p=q.front();q.pop(); seen[p]=1; while(abs(b[p]-a[p])){ if(b[p]-a[p]>0){ ans.emplace_back(p,'R'); a[p]++; } else{ ans.emplace_back(p,'L'); a[p]--; } } if(p+1<=n&&!seen[p+1]){q.push(p+1);seen[p+1]=1;} if(p-1>=1&&!seen[p-1]){q.push(p-1);seen[p-1]=1;} } cout<