#!/usr/bin/env python # -*- coding: utf-8 -*- W = int(input()) N = int(input()) J = list(map(int,input().split())) M = int(input()) C = list(map(int,input().split())) flow = [[1 for i in range(N)] for j in range(M)] for i in range(M): xs = list(map(int,input().split())) for j in xs[1:]: flow[i][j-1] = 0 for animator,a_v in sorted(enumerate(J),key=lambda x:-x[1]): directors = sorted([(C[i],i) for i in range(M) if flow[i][animator] == 1],key=lambda x:-x[0]) for d_v,d in directors: volume = min(C[d],J[animator]) C[d] -= volume J[animator] -= volume W -= volume if W <= 0: break if W <= 0: break else: print('BANSAKUTSUKITA') quit() print('SHIROBAKO')