from collections import deque class EDOMONDS_KARP(): def __init__(self, N, s, t): self.N = N; self.s = s; self.t = t self.cap = [[0]*N for _ in range(N)] self.link = [[] for _ in range(N)] def add_edge(self, u, v, c): self.cap[u][v] = c self.link[u].append(v) self.link[v].append(u) def max_flow(self): N = self.N; s = self.s; t = self.t f = 0 flow = [[0]*N for _ in range(N)] while True: m, prev = self.bfs(flow) if m == 0: break f += m v = t while v != s: u = prev[v] flow[u][v] += m flow[v][u] -=m v = u return (f, flow) def bfs(self, flow): N = self.N; s = self.s; t = self.t cap = self.cap link = self.link prev = [-1]*N; prev[s] = -2 m = [0]*N; m[s] = float('inf') q = deque([s]) while q: u = q.popleft() for v in link[u]: if cap[u][v] - flow[u][v] > 0 and prev[v] == -1: prev[v] = u m[v] = min(m[u], cap[u][v] - flow[u][v]) if v != t: q.append(v) else: return (m[t], prev) return (0, prev) W = int(input()) N = int(input()) J = list(map(int, input().split())) M = int(input()) C = list(map(int, input().split())) S, T = 0, N + M + 1 EK = EDOMONDS_KARP(N + M + 2, S, T) for i in range(1, N + 1): EK.add_edge(S, i, J[i - 1]) for i in range(1, M + 1): EK.add_edge(i + N, T, C[i - 1]) for y in range(N + 1, N + M + 1): ls = list(map(int, input().split())) X = set(ls[1:]) for x in range(1, N + 1): if not x in X: EK.add_edge(x, y, float('inf')) f, _ = EK.max_flow() print("SHIROBAKO" if f >= W else "BANSAKUTSUKITA")