#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } const int LIM=20; signed main(){ int N,M;cin>>N>>M; vector A(M),B(M); cin>>A>>B; for(auto &x:A) x--; for(auto &x:B) x--; if(N<=LIM){ vector> dp(M+1,vector(N,0)); vector> pre(M+1,vector(N,0)); rep(i,N) dp[0][i]=1; rep(i,M){ rep(j,N){ if(dp[i][j]){ if(j) dp[i+1][j-1]=1,pre[i+1][j-1]=j; if(j+1 res; for(int i=M;i>=0;i--){ res.push_back(p+1); p=pre[i][p]; } reverse(ALL(res)); for(auto &x:res) cout< res; int p=N/2; res.push_back(p); for(int i=0;i=0 and p-1!=A[i] and p-1!=B[i]){ p=p-1; res.push_back(p); }else if(p!=A[i] and p!=B[i]){ res.push_back(p); }else if(p+1