class Fenwick_Tree: def __init__(self, N, A=None): self.N=N if A==None: self.data=[0]*N else: assert len(A)==N self.data=A self.__build() def __build(self): data=self.data for i in range(1, self.N+1): if i+(i&(-i))<=self.N: data[i+(i&(-i))-1]+=data[i-1] def add(self, i, x): i+=1 data=self.data while i<=self.N: data[i-1]+=x i+=i&(-i) def sum(self, i): S=0 data=self.data while i: S+=data[i-1] i-=i&(-i) return S def range_sum(self,l,r): return self.sum(r)-self.sum(l) def bisect_left(self, x, default=-1): i=0 k=1<>=1 return i if x else default def bisect_right(self, x, default=-1): i=0 k=1<>=1 return i if i=0: return self.Fenwick.bisect_left(self.Fenwick.sum(x), default) else: return default def next(self, x, mode=True, default=-1): """ S に含まれる x 以上の要素のうち, 最大値を求める. x: int mode: False のときは "以上" が "より大きい" になる. """ if not mode: x+=1 return self.Fenwick.bisect_right(self.Fenwick.sum(x), default) def less_count(self, x, mode=False): """ x 未満の元の個数を求める. x: int mode: mode=True ならば, "未満" が "以下" になる. """ if mode: x+=1 return self.Fenwick.sum(x) def more_count(self, x, mode=False): """ x より大きい元の個数を求める. x: int mode: mode=True ならば, "より大きい" が "以上" になる. """ return len(self)-self.less_count(x, not mode) def kth_min(self, k, default=-1): """ k 番目に小さい元を求める. """ if 1<=k<=len(self): return self[k-1] else: return default def kth_max(self, k, default=-1): """ k 番目に大きい元を求める. """ if 1<=k<=len(self): return self[~(k-1)] else: return default #================================================== def AND(x,y): return (x and y) def OR(x,y): return (x or y) def XOR(x,y): return (x^y) def IMP(x,y): return ((not x) or y) #================================================== def solve(): N=int(input()) X=list(input().split()) Y=[None]+list(input().split()) S=list(map(int,input().split())) X=[x=="True" for x in X] U=Ordered_Set(N, S=[1]*N) left=[i-1 if i>0 else -1 for i in range(N)] right=[i+1 if i