# https://yukicoder.me/problems/no/3638 from collections import deque B = 30 H = 9007199254740997 # ソースコードの出典URL: https://github.com/LyricalMaestro/at_coder_snippets/blob/af67863a2fe7f16cce8325bbc531f89968bfa525/src/segment_tree.py class SegmentTree: """ 非再帰版セグメント木。 更新は「加法」、取得は「最大値」のもの限定。 """ def __init__(self, init_array): n = 1 while n < len(init_array): n *= 2 self.size = n self.array = [0] * (2 * self.size) self.weights = [0] * (2 * self.size) for i, a in enumerate(init_array): self.array[self.size + i] = a self.weights[self.size +i] = 1 pow_b = 1 self.pow_b_list = [0] * (len(init_array) + 1) for i in range(len(init_array) + 1): self.pow_b_list[i] = pow_b pow_b *= B pow_b %= H end_index = self.size start_index = end_index // 2 while start_index >= 1: for i in range(start_index, end_index): self.weights[i] = self.weights[2 * i] + self.weights[2 * i + 1] self.array[i] = self._op(self.array[2 * i], self.array[2 * i + 1], self.weights[2 * i + 1]) end_index = start_index start_index = end_index // 2 def _op(self, left , right, r_weight): x = left * self.pow_b_list[r_weight] x %= H x += right x %= H return x def set(self, x, a): index = self.size + x self.array[index] = a while index > 1: index //= 2 self.array[index] = self._op(self.array[2 * index], self.array[2 * index + 1], self.weights[2 * index + 1]) def get_hash(self, l, r): L = self.size + l; R = self.size + r r_queue = deque() l_queue = deque() # 2. 区間[l, r)の最大値を求める s = 0 while L < R: if R & 1: R -= 1 r_queue.appendleft(R) if L & 1: l_queue.append(L) L += 1 L >>= 1; R >>= 1 while len(l_queue) > 0: l = l_queue.popleft() s = self._op(s, self.array[l], self.weights[l]) while len(r_queue) > 0: l = r_queue.popleft() s = self._op(s, self.array[l], self.weights[l]) return s def main(): N, Q = map(int, input().split()) S = input() queries = [] for _ in range(Q): values = input().split() queries.append(values) pow_b_list = [0] * (N + 1) pow_b = 1 for i in range(N + 1): pow_b_list[i] = pow_b pow_b *= B pow_b %= H s_list = [ord(s) - ord("a") + 1 for s in S] for values in queries: if values[0] == "1": _, i, c = values i = int(i) - 1 c = ord(c) - ord("a") + 1 s_list[i] = c else: _, t = values hash0 = 0 for t0 in t: hash0 *= B hash0 %= H hash0 += ord(t0) - ord("a") + 1 hash0 %= H is_ok = False if len(t) <= N: hash1 = 0 for i in range(len(t)): hash1 *= B hash1 %= H hash1 += s_list[i] hash1 %= H is_ok = hash1 == hash0 for i in range(len(t), N): hash1 *= B hash1 %= H hash1 += s_list[i] hash1 %= H hash1 -= (s_list[i - len(t)] * pow_b_list[len(t)]) % H hash1 %= H if hash1 == hash0: is_ok = True if is_ok: print("Yes") else: print("No") if __name__ == "__main__": main()