#include <bits/stdc++.h>
using namespace std;
const int N=510, M=(160*280+2*N)*2, inf=1e9;
int ver[M],nxt[M],fl[M],head[N],tot=1;
int q[N],d[N],nh[N];
int n,m,S,T;
void add(int x,int y,int z){
ver[++tot]=y,fl[tot]=z,nxt[tot]=head[x],head[x]=tot;
}
bool bfs(){
memset(d,0,sizeof d);
d[S]=1,q[0]=S,nh[S]=head[S];
int hh=0,tt=1;
while(hh<tt){
int x=q[hh++];
for(int i=head[x];i;i=nxt[i]){
int y=ver[i];
if(d[y] || !fl[i])continue;
d[y]=d[x]+1, nh[y]=head[y];
if(y==T)return true;
q[tt++]=y;
}
}
return false;
}
int find(int x,int limit){
if(x==T)return limit;
int flow=0;
for(int i=nh[x];i && flow<limit;i=nxt[i]){
nh[x]=i;
int y=ver[i];
if(d[y]!=d[x]+1 || !fl[i])continue;
int t=find(y,min(fl[i],limit-flow));
if(t)flow+=t, fl[i]-=t, fl[i^1]+=t;
else d[y]=0;
}
return flow;
}
int dinic(){
int res=0,flow;
for(;bfs();)
while(flow=find(S,inf))res+=flow;
return res;
}
int main(){
cin>>m>>n;
S=0, T=n+m+1;
int x,y,cnt=0;
for(int i=1;i<=m;i++)
cin>>x, add(S,i,x), add(i,S,0),cnt+=x;
for(int i=1;i<=n;i++)
cin>>y, add(m+i,T,y), add(T,m+i,0);
for(int i=1,j=1;i<=m;j=(j%n)+1, i+=(j==1))
add(i,m+j,1),add(m+j,i,0);
if(dinic()==cnt){
cout<<1<<endl;
for(int i=2,j=1;i<=tot;i+=2){
x=ver[i^1], y=ver[i];
if(x<1 || x>m || y<=m || y==T)continue;
if(fl[i])continue;
if(x!=j)cout<<endl, j++;
cout<<y-m<<" ";
}
}else
cout<<0<<endl;
return 0;
}