super_set=set(map(int,input().split())) count=True n=int(input()) for i in range(n): normal_set=set(map(int,input().split())) if len(super_set)>len(normal_set): if not super_set.issuperset(normal_set): count=False print(count)