import sequtils,strutils proc L:any=stdin.readLine.parseInt proc R:any=stdin.readLine.split.map(parseInt) var w=L() n=L() J=R() m=L() C=R() s=n+m t=s+1 F=newSeqWith(t+1,newSeq[tuple[t,p,r:int]]()) U:seq[int] z=0 proc a(s,t,p:int)=(F[s]&=(t,p,F[t].len);F[t]&=(s,0,F[s].len-1)) for i,j in J:a s,i,j for i,c in C:a n+i,t,c for c in n..0:(F[s][i].p-=d;F[e.t][e.r].p+=d;return d) while true: U=newSeq[int]t+1 let f=q(s,t,9999) if f==0:(if w>z:quit "BANSAKUTSUKITA",0 else:quit "SHIROBAKO",0) z+=f