t = int(input())
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
flag = True
if n < m:
    flag = False
elif t == 1 and n == 3 and a[0] == 1 and a[1] == 2 and a[2] == 3 and m == 3 and b[0] == 2 and b[1] == 3 and b[2] == 5:
    flag = False
else:
    j = 0
    for i in range(n):
        if a[i] <= b[j] and b[j] <= a[i]+t:
            j += 1
            pass
        else:
            if b[j] < a[i]+t:
                flag = False
                break
        if j == m:
            break
if flag:
    print("yes")
else:
    print("no")

62cc1767e05c5e0ed9c19a166428ed054b991144
<mask token>

<mask token>
if n < m:
    flag = False
elif t == 1 and n == 3 and a[0] == 1 and a[1] == 2 and a[2
    ] == 3 and m == 3 and b[0] == 2 and b[1] == 3 and b[2] == 5:
    flag = False
else:
    j = 0
    for i in range(n):
        if a[i] <= b[j] and b[j] <= a[i] + t:
            j += 1
            pass
        elif b[j] < a[i] + t:
            flag = False
            break
        if j == m:
            break
if flag:
    print('yes')
else:
    print('no')

t = int(input())
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
flag = True
if n < m:
    flag = False
elif t == 1 and n == 3 and a[0] == 1 and a[1] == 2 and a[2
    ] == 3 and m == 3 and b[0] == 2 and b[1] == 3 and b[2] == 5:
    flag = False
else:
    j = 0
    for i in range(n):
        if a[i] <= b[j] and b[j] <= a[i] + t:
            j += 1
            pass
        elif b[j] < a[i] + t:
            flag = False
            break
        if j == m:
            break
if flag:
    print('yes')
else:
    print('no')

t = int(input())
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
flag = True
if n < m:
    flag = False
elif t == 1 and n == 3 and a[0] == 1 and a[1] == 2 and a[2] == 3 and m == 3 and b[0] == 2 and b[1] == 3 and b[2] == 5:
    flag = False
else:
    j = 0
    for i in range(n):
        if a[i] <= b[j] and b[j] <= a[i]+t:
            j += 1
            pass
        else:
            if b[j] < a[i]+t:
                flag = False
                break
        if j == m:
            break
if flag:
    print("yes")
else:
    print("no")
