def main(): import sys input = sys.stdin.read data = input().split() idx = 0 N = int(data[idx]) idx += 1 M = int(data[idx]) idx += 1 A = list(map(int, data[idx:idx+M])) idx += M Q = int(data[idx]) idx += 1 B = list(map(lambda x: int(x)-1, data[idx:idx+Q])) # convert to zero-based indexes pos = A.copy() # current positions of each piece (sorted) possible = True for bi in B: if not possible: break i = bi current = pos[i] # Try moving right first new_pos = current + 1 valid_right = True if new_pos > N: valid_right = False else: if i > 0 and new_pos <= pos[i-1]: valid_right = False if i < M-1 and new_pos >= pos[i+1]: valid_right = False if valid_right: pos[i] = new_pos continue # Try moving left new_pos = current - 1 valid_left = True if new_pos < 1: valid_left = False else: if i > 0 and new_pos <= pos[i-1]: valid_left = False if i < M-1 and new_pos >= pos[i+1]: valid_left = False if valid_left: pos[i] = new_pos continue # Both directions invalid possible = False print("YES" if possible else "NO") if __name__ == '__main__': main()