#include<bits/stdc++.h>
using namespace std;
ifstream fi("DATHUC.inp");
ofstream fo("DATHUC.out");
int main(){
 int m,n,x;
 fi>>m>>n;
 int t=max(m,n);
 vector<int>a(t+1,0);
 for(int i=m;i>=0;--i)fi>>a[i];
 int ans=t;
 for(int i=n;i>=0;--i){
        fi>>x;
        if (a[i]+x==0)ans--;
        a[i]=a[i]+x;

 }
  fo<<ans<<endl;
for(int i=ans;i>=0;--i)fo<<a[i]<<' ';
}
