class maxFlow{ import std.typecons, std.conv, std.algorithm, std.stdio; alias T=int; // type of flow alias Edge=Tuple!(int, "to", int, "rev", T, "cap"); Edge[][] g; bool[] vis; auto inf=(1_000_000_000).to!(T); this(int sz){ g.length=sz; vis.length=sz; } void addEdge(int from, int to, T cap){ g[from]~=Edge(to, (g[to].length).to!(int), cap); g[to]~=Edge(from, (g[from].length-1).to!(int), (0).to!(T)); } T flow(int i, T curf, int sink){ if(i==sink) return curf; vis[i]=true; foreach(ref e; g[i]){ if(vis[e.to] || e.cap==0) continue; auto tmpf=flow(e.to, min(curf, e.cap), sink); if(tmpf>0){ e.cap-=tmpf; g[e.to][e.rev].cap+=tmpf; return tmpf; } } return 0; } T ford(int source, int sink){ auto maxf=(0).to!(T); while(true){ fill(vis, false); auto f=flow(source, inf, sink); if(f>0) maxf+=f; else return maxf; } } } void main(){ import std.stdio, std.string, std.conv, std.algorithm; int w; rd(w); int n; rd(n); auto js=readln.split.to!(int[]); int m; rd(m); auto cs=readln.split.to!(int[]); auto mf=new maxFlow(n+m+2); auto s=n+m, t=n+m+1; foreach(int i; 0..n) mf.addEdge(s, i, js[i]); foreach(int j; 0..m) mf.addEdge(j+n, t, cs[j]); const inf=1_000_000; foreach(int j; 0..m){ auto args=readln.split.to!(int[]); for(int idx=1, i=0; idx<=args.length; idx++, i++){ if(idx==args.length){ while(i=w){ writeln("SHIROBAKO"); }else{ writeln("BANSAKUTSUKITA"); } } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } }