#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; struct flow_network { int n; struct edge { int v; ll c; int rev; }; vector< vector > G; flow_network(int _n) : n(_n), G(_n) {} void add_edge(int u, int v, ll c) { edge e = {v, c, G[v].size()}, _e = {u, 0, G[u].size()}; G[u].push_back(e); G[v].push_back(_e); } ll dfs(int u, int t, ll f, vector& vis) { if (u == t) return f; vis[u] = true; for (int i = 0; i < G[u].size(); i++) { edge& e = G[u][i]; if (vis[e.v] || e.c == 0) continue; ll d = min(e.c, dfs(e.v, t, min(f, e.c), vis)); if (d == 0) continue; e.c -= d; G[e.v][e.rev].c += d; return d; } return 0; } ll max_flow(int s, int t) { ll res = 0; for (;;) { vector vis(n); ll f = dfs(s, t, LLONG_MAX, vis); if (f == 0) return res; res += f; } } }; int main() { int W; cin >> W; int N; cin >> N; vector J(N); for (int i = 0; i < N; i++) cin >> J[i]; int M; cin >> M; vector C(M); for (int j = 0; j < M; j++) cin >> C[j]; vector > X(M); for (int j = 0; j < M; j++) { int Q; cin >> Q; while (Q--) { int x; cin >> x; X[j].insert(x - 1); } } flow_network fn(N + M + 3); int s = N + M, t = N + M + 1, ss = N + M + 2; for (int i = 0; i < N; i++) fn.add_edge(s, i, J[i]); for (int j = 0; j < M; j++) fn.add_edge(N + j, t, C[j]); for (int j = 0; j < M; j++) for (int i = 0; i < N; i++) { if (X[j].count(i)) continue; fn.add_edge(i, N + j, 10000); } fn.add_edge(ss, s, W); int x = fn.max_flow(s, t); cout << (x == W ? "SHIROBAKO" : "BANSAKUTSUKITA") << endl; }