When Misha hits his favorite gym, he comes across an interesting problem with the barbell. In the gym, someone always leaves the weight plates in the strangest places you can imagine and sometime it's difficult to equip the barbell the way you want. Let's imagine that you have N weight plates placed in any order (remember that any gym has no more than K different types of weight plates and all weights are square-free). As a preliminary step towards solving this problem, Misha wants to simulate a simple gym, and for this purpose you have to deal with some queries:

- [1 I X] Set the weight of the ith weight plate to value X.

- [2 L R] Reverse the sequence of weight plates in the interval from L to R, where 1 ≤ L ≤ R ≤ N.

- [3 L R W] Check the interval from L to R to find out if you can make the weight W using only weight plates on this interval. (Note: this type of query will appear no more than P times)

Please help Misha in solving this problem. 

-----Input-----
First line of input contains the number of weight plates N, and number of queries Q. Next line contains N integers w1, w2, ..., wN, where wi is the weight of the ith weight plate. Next Q lines contain some queries described above. 

-----Output-----
For all queries of the third type: print "Yes" if your check returns a positive outcome, and "No" otherwise.

-----Constraints-----
- 1 ≤ N, W, Q ≤ 105
- K ≤ 10
- P ≤ 1000
- All numbers in the input are positive integers and ≤ 105.
- All the weights are square-free.

-----Subtasks-----
- Subtask 1: 1 ≤ N ≤ 103, 1 ≤ W ≤ 103, Q = 1 - 10 pts.

- Subtask 2: 1 ≤ N ≤ 103, 1 ≤ W ≤ 103, 1 ≤ Q ≤ 103, P ≤ 100 - 15 pts
- Subtask 3: 1 ≤ N ≤ 104, 1 ≤ W ≤ 104, 1 ≤ Q ≤ 104, P ≤ 300 - 25 pts.

- Subtask 4: 1 ≤ N ≤ 105, 1 ≤ W ≤ 105, 1 ≤ Q ≤ 105, K ≤ 2 - 20 pts.

- Subtask 5: Original constraints - 30 pts.

-----Example-----First
Input:5 10
1 2 3 5 6
3 2 3 3
3 2 3 4
3 2 3 5
2 2 5
3 2 4 8
1 2 1
3 2 4 8
2 1 4 
3 2 4 3 
3 1 5 7 

Output:Yes
No
Yes
Yes
Yes
No
YesSecond
Input:3 4
2013 2015 2017
3 1 3 4030
1 1 111
3 1 3 4030
3 1 2 111

Output:Yes
No
Yes

-----Explanation:-----First test explanation (step by step)
1 2 3 5 6
3 2 3 3 ([2, 3] 3=3 => Yes)
3 2 3 4 ([2, 3] can't make 4 => No)
3 2 3 5 ([2, 3] 2+3=5 => Yes)
2 2 5 (Reverse: [1, 6, 5, 3, 2])
3 2 4 8 ([6, 5, 3] 5+3=8 => Yes)
1 2 1 (Set: [1, 1, 5, 3, 2])
3 2 4 8 ([1, 5, 3] 5+3=8 => Yes)
2 1 4  (Reverse: [3, 5, 1, 1, 2])
3 2 4 3 ([5, 1, 1] can't make 3 => No)
3 1 5 7 ([3, 5, 1, 1, 2] 2+1+1+3=7 => Yes)

Difficulty: HARD

Starter code:

Solutions:
def fx(s, n, xsum):
	sub = [[None for x in range(n + 2)] for y in range(xsum + 2)]
	for i in range(n + 1):
		sub[0][i] = True
	for i in range(1, xsum + 1):
		sub[i][0] = False
	for i in range(1, xsum + 1):
		for j in range(1, n + 1):
			sub[i][j] = sub[i][j - 1]
			if i >= s[j - 1]:
				sub[i][j] = sub[i][j] or sub[i - s[j - 1]][j - 1]
	if sub[xsum][n]:
		print('Yes')
	else:
		print('No')
(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
for _ in range(t):
	q = list(map(int, input().split()))
	if q[0] == 1:
		a[q[1] - 1] = q[2]
		continue
	if q[0] == 2:
		w = a[q[1] - 1:q[2]]
		a[q[1] - 1:q[2]] = w[::-1]
		continue
	if q[0] == 3:
		e = a[q[1] - 1:q[2]]
		if q[3] < min(e) or q[3] > sum(e):
			print('No')
			continue
		if q[3] in e:
			print('Yes')
			continue
		fx(e, len(e), q[3])


def subsetsum(array, g):
	if g == 0 or g < 1:
		return False
	elif len(array) == 0:
		return False
	elif array[0] == g:
		return True
	else:
		return subsetsum(array[1:], g - array[0]) or subsetsum(array[1:], g)
(n, q) = [int(i) for i in input().split()]
w = [int(i) for i in input().split()]
for qq in range(q):
	x = [i for i in input().split()]
	a = int(x[0])
	if a == 1:
		w[int(x[1]) - 1] = int(x[2])
	elif a == 2:
		l = int(x[1]) - 1
		r = int(x[2]) - 1
		w = w[:l] + w[r:l - 1:-1] + w[r + 1:]
	else:
		l = int(x[1]) - 1
		r = int(x[2])
		if subsetsum(w[l:r], int(x[3])):
			print('Yes')
		else:
			print('No')


def subsetsum(nums, tgt):
	sums = {}
	for n in nums[::2]:
		for (k, v) in list(sums.items()) + [(0, [])]:
			newsum = k + n
			if newsum not in sums:
				sums[newsum] = v + [n]
				if newsum == tgt:
					return sums[tgt]
	difs = {tgt: []}
	for n in nums[1::2]:
		for (k, v) in list(difs.items()):
			newdif = k - n
			if newdif not in difs:
				difs[newdif] = v + [n]
				if newdif in sums:
					return sums[newdif] + difs[newdif]
	return []
(n, q) = input().split()
(n, q) = (int(n), int(q))
a = input().split()
a = [int(x) for x in a]
while q > 0:
	s = input().split()
	s = [int(x) for x in s]
	l = s[1]
	r = s[2]
	if s[0] == 1:
		a[l - 1] = r
	elif s[0] == 2:
		i = l - 1
		j = r - 1
		while i <= j:
			swap = a[i]
			a[i] = a[j]
			a[j] = swap
			i += 1
			j -= 1
	else:
		w = s[3]
		b = a[l - 1:r] + [0]
		if len(subsetsum(b, w)) > 0:
			print('Yes')
		else:
			print('No')
	q = q - 1


def isSubSetSum(a, n, w):
	subset = [[0 for x in range(n + 1)] for y in range(w + 1)]
	for i in range(n + 1):
		subset[0][i] = 1
	for i in range(1, w + 1):
		subset[i][0] = 0
	for i in range(1, w + 1):
		for j in range(1, n + 1):
			subset[i][j] = subset[i][j - 1]
			if i >= a[j - 1]:
				if subset[i][j] == 1 or subset[i - a[j - 1]][j - 1] == 1:
					subset[i][j] = 1
	return subset[w][n]
(n, q) = input().split()
(n, q) = (int(n), int(q))
a = input().split()
a = [int(x) for x in a]
while q > 0:
	s = input().split()
	s = [int(x) for x in s]
	l = s[1]
	r = s[2]
	if s[0] == 1:
		a[l - 1] = r
	elif s[0] == 2:
		i = l - 1
		j = r - 1
		while i <= j:
			swap = a[i]
			a[i] = a[j]
			a[j] = swap
			i += 1
			j -= 1
	else:
		w = s[3]
		b = a[l - 1:r]
		if isSubSetSum(b, len(b), w) == 1:
			print('Yes')
		else:
			print('No')
	q = q - 1


import sys

def isSubsetSum(se, n, su):
	subset = [[0] * (n + 1) for i in range(su + 1)]
	for i in range(0, n + 1):
		subset[0][i] = 1
	for i in range(1, su + 1):
		subset[i][0] = 0
	for i in range(1, su + 1):
		for j in range(1, n + 1):
			subset[i][j] = subset[i][j - 1]
			if i >= se[j - 1]:
				subset[i][j] = subset[i][j] or subset[i - se[j - 1]][j - 1]
	return subset[su][n]
(n, q) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
while q > 0:
	q -= 1
	s = []
	s = [int(i) for i in input().split()]
	if s[0] == 3:
		l1 = s[1]
		r = s[2]
		w = s[3]
		if isSubsetSum(l[l1 - 1:r], r - l1 + 1, w) == True:
			sys.stdout.write('Yes\n')
		else:
			sys.stdout.write('No\n')
	elif s[0] == 2:
		l1 = s[1]
		r = s[2]
		i = l1 - 1
		j = r - 1
		while i < j:
			(l[i], l[j]) = (l[j], l[i])
			j -= 1
			i += 1
	else:
		i = s[1]
		x = s[2]
		l[i - 1] = x


import sys

def subsetsum(array, num):
	if num == 0 or num < 1:
		return False
	elif len(array) == 0:
		return False
	elif array[0] == num:
		return True
	else:
		return subsetsum(array[1:], num - array[0]) or subsetsum(array[1:], num)
(n, q) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
while q > 0:
	q -= 1
	s = []
	s = [int(i) for i in input().split()]
	if s[0] == 3:
		l1 = s[1]
		r = s[2]
		w = s[3]
		if subsetsum(l[l1 - 1:r], w) == True:
			sys.stdout.write('Yes\n')
		else:
			sys.stdout.write('No\n')
	elif s[0] == 2:
		l1 = s[1]
		r = s[2]
		i = l1 - 1
		j = r - 1
		while i < j:
			(l[i], l[j]) = (l[j], l[i])
			j -= 1
			i += 1
	else:
		i = s[1]
		x = s[2]
		l[i - 1] = x


def subsetsum(array, num):
	if num == 0 or num < 1:
		return False
	elif len(array) == 0:
		return False
	elif array[0] == num:
		return True
	else:
		return subsetsum(array[1:], num - array[0]) or subsetsum(array[1:], num)
(n, q) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
while q > 0:
	q -= 1
	s = []
	s = [int(i) for i in input().split()]
	if s[0] == 3:
		l1 = int(s[1])
		r = int(s[2])
		w = int(s[3])
		if subsetsum(l[l1 - 1:r], w) == True:
			print('Yes')
		else:
			print('No')
	elif s[0] == 2:
		l1 = int(s[1])
		r = int(s[2])
		l1 -= 1
		r -= 1
		k = l[l1:r + 1]
		k.reverse()
		l = l[:l1] + k + l[r + 1:]
	else:
		i = int(s[1])
		x = int(s[2])
		l[i - 1] = x


def solve(w, sum):
	n = len(w)
	dp = []
	for i in range(n + 1):
		dp.append([0] * (sum + 1))
	for i in range(1, sum + 1):
		dp[0][i] = 0
	for i in range(n + 1):
		dp[i][0] = 1
	for i in range(1, n + 1):
		for j in range(1, sum + 1):
			dp[i][j] = dp[i - 1][j]
			if dp[i][j] == 0 and j >= w[i - 1]:
				dp[i][j] = dp[i - 1][j - w[i - 1]]
	return dp[n][sum]
(n, q) = list(map(int, input().split()))
w = list(map(int, input().split()))
for i in range(q):
	s = list(map(int, input().split()))
	if s[0] == 1:
		w[s[1] - 1] = s[2]
	elif s[0] == 2:
		w = w[:s[1] - 1] + w[s[1] - 1:s[2]][::-1] + w[s[2]:]
	elif solve(w[s[1] - 1:s[2]], s[3]) == 1:
		print('Yes')
	else:
		print('No')


def subsetsum(array, num):
	if num == 0 or num < 1:
		return False
	elif len(array) == 0:
		return False
	elif array[0] == num:
		return True
	else:
		return subsetsum(array[1:], num - array[0]) or subsetsum(array[1:], num)
(n, q) = list(map(int, input().split()))
w = list(map(int, input().split()))
for i in range(q):
	s = list(map(int, input().split()))
	if s[0] == 1:
		w[s[1] - 1] = s[2]
	elif s[0] == 2:
		w = w[:s[1] - 1] + w[s[1] - 1:s[2]][::-1] + w[s[2]:]
	elif subsetsum(w[s[1] - 1:s[2]], s[3]):
		print('Yes')
	else:
		print('No')


def check(w, x, n):
	if w == 0:
		return True
	if n == 0 and w != 0:
		return False
	if x[n - 1] > w:
		return check(w, x, n - 1)
	return check(w, x, n - 1) or check(w - x[n - 1], x, n - 1)
(n, qN) = list(map(int, input().rstrip().split()))
data = [int(i) for i in input().rstrip().split()]
for Q in range(qN):
	q = [int(i) for i in input().rstrip().split()]
	if q[0] == 1:
		data[q[1] - 1] = q[2]
	elif q[0] == 2:
		(i, j) = (q[1] - 1, q[2] - 1)
		new = data[:i] + data[i:j + 1][::-1] + data[j + 1:]
		data = new
	else:
		print('Yes' if check(q[3], data[q[1] - 1:q[2]], q[2] - q[1] + 1) else 'No')


import sys
from itertools import combinations

def solve(A, x):
	if x < 0 or x > sum(A):
		return False
	sub_sum = [False] * (x + 1)
	sub_sum[0] = True
	p = 0
	while not sub_sum[x] and p < len(A):
		a = A[p]
		q = x
		while not sub_sum[x] and q >= a:
			if not sub_sum[q] and sub_sum[q - a]:
				sub_sum[q] = True
			q -= 1
		p += 1
	return sub_sum[x]

def main():
	(n, w) = list(map(int, sys.stdin.readline().split()))
	arr = list(map(int, sys.stdin.readline().split()))
	for i in range(w):
		val = list(map(int, sys.stdin.readline().split()))
		if val[0] == 1:
			arr[val[1] - 1] = val[2]
		elif val[0] == 2:
			a = val[1] - 1
			b = val[2]
			arr[a:b] = reversed(arr[a:b])
		elif solve(arr[val[1] - 1:val[2]], val[3]):
			print('Yes')
		else:
			print('No')
main()


a = []
b = []
c = []
temp = []
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def find(temp, f):
	q = -1
	while q < len(temp) - 1 and temp[q + 1] <= f:
		q = q + 1
		if temp[q] == f:
			return 1
	if q == -1:
		return 0
	else:
		f = f - temp[q]
		flag = find(temp[0:q], f)
		return flag
for i in range(0, a[1]):
	c = list(map(int, input().split()))
	flag = 0
	if c[0] == 3:
		temp = b[c[1] - 1:c[2]]
		temp.sort()
		j = -1
		f = int(c[3])
		while j < len(temp) - 1 and temp[j + 1] <= f:
			j = j + 1
			if temp[j] == f:
				flag = 1
				break
		if flag == 1:
			print('Yes')
			continue
		while j >= 1:
			f = c[3] - temp[j]
			flag = find(temp[0:j], f)
			if flag == 1:
				break
			else:
				j = j - 1
		if flag == 1:
			print('Yes')
		else:
			print('No')
	if c[0] == 1:
		b[c[1] - 1] = c[2]
	if c[0] == 2:
		b[c[1] - 1:c[2]] = reversed(b[c[1] - 1:c[2]])