#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef complex P; typedef pair pii; #define REP(i,n) for(ll i=0;i g[V_MAX]; bool used[V_MAX]; void add_edge(int from,int to,int cap){ g[from].push_back((edge){to,cap,g[to].size()}); g[to].push_back((edge){from,0,g[from].size()-1}); } int dfs(int v,int t,int f){ if(v==t)return f; used[v]=true; REP(i,g[v].size()){ edge &e = g[v][i]; if(!used[e.to]&&e.cap>0){ int d = dfs(e.to,t,min(f,e.cap)); if(d>0){ e.cap -= d; g[e.to][e.rev].cap += d; return d; } } } return 0; } int ford_fulkerson(int s,int t){ int flow = 0; while(true){ REP(i,V_MAX)used[i]=false; int f = dfs(s,t,1e9); if(f==0)break; flow += f; } return flow; } int main(){ int w,n; cin>>w>>n; vi j(n); REP(i,n)cin>>j[i]; int m; cin>>m; vi c(m); REP(i,m)cin>>c[i]; vector G(n,vi(m,1)); REP(i,m){ int q; cin>>q; REP(_,q){ int x; cin>>x; G[x-1][i] = 0; } } // s: n+m // t: n+m+1 // genga: 0~n-1 // sakuga: n~n+m-1 REP(i,n) add_edge(n+m,i,j[i]); REP(i,m) add_edge(n+i,n+m+1,c[i]); REP(i,n)REP(j,m){ if(G[i][j]==0)continue; add_edge(i,n+j,1e9); } int f = ford_fulkerson(n+m,n+m+1); cout << (f>=w?"SHIROBAKO":"BANSAKUTSUKITA") << endl; return 0; }