#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main() { ll w; cin >> w; ll n; cin >> n; ll j[n]; for (int i = 0; i < n; i++) { cin >> j[i]; } ll m; cin >> m; ll c[m]; for (int i = 0; i < m; i++) { cin >> c[i]; } bool no[n][m]; memset(no, false, sizeof(no)); for (int i = 0; i < m; i++) { ll q; cin >> q; for (int l = 0; l < q; l++) { ll t; cin >> t; no[t-1][i] = true; } } ll sum = 0; for (int i = 0; i < n; i++) { ll p = -1; for (int l = 0; l < m; l++) { if (!no[i][l]) { p = l; break; } } if (p == -1) { continue; } for (int l = 0; l < m; l++) { if (c[p] < c[l] && !no[i][l]) { p = l; } } sum += min(c[p], j[i]); c[p] -= min(c[p], j[i]); } if (sum >= w) { std::cout << "SHIROBAKO" << std::endl; }else { std::cout << "BANSAKUTSUKITA" << std::endl; } }