T = int(input())


def check_subset(set_a, set_b):
    is_subset = True
    for item in set_a:
        if item not in set_b:
            is_subset = False
            return is_subset
    return is_subset


for i in range(T):
    a = int(input())
    set_a = set(map(int, input().split()))
    b = int(input())
    set_b = set(map(int, input().split()))
    print(check_subset(set_a, set_b))

2e3a71ae65fa04ef5d9896693213f047da415960
<mask token>

<mask token>


def check_subset(set_a, set_b):
    is_subset = True
    for item in set_a:
        if item not in set_b:
            is_subset = False
            return is_subset
    return is_subset


<mask token>

<mask token>


def check_subset(set_a, set_b):
    is_subset = True
    for item in set_a:
        if item not in set_b:
            is_subset = False
            return is_subset
    return is_subset


for i in range(T):
    a = int(input())
    set_a = set(map(int, input().split()))
    b = int(input())
    set_b = set(map(int, input().split()))
    print(check_subset(set_a, set_b))

T = int(input())


def check_subset(set_a, set_b):
    is_subset = True
    for item in set_a:
        if item not in set_b:
            is_subset = False
            return is_subset
    return is_subset


for i in range(T):
    a = int(input())
    set_a = set(map(int, input().split()))
    b = int(input())
    set_b = set(map(int, input().split()))
    print(check_subset(set_a, set_b))
