Are you going to Scarborough Fair?

Parsley, sage, rosemary and thyme.

Remember me to one who lives there.

He once was the true love of mine.

Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.

Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.

Although the girl wants to help, Willem insists on doing it by himself.

Grick gave Willem a string of length n.

Willem needs to do m operations, each operation has four parameters l, r, c_1, c_2, which means that all symbols c_1 in range [l, r] (from l-th to r-th, including l and r) are changed into c_2. String is 1-indexed.

Grick wants to know the final string after all the m operations.


-----Input-----

The first line contains two integers n and m (1 ≤ n, m ≤ 100).

The second line contains a string s of length n, consisting of lowercase English letters.

Each of the next m lines contains four parameters l, r, c_1, c_2 (1 ≤ l ≤ r ≤ n, c_1, c_2 are lowercase English letters), separated by space.


-----Output-----

Output string s after performing m operations described above.


-----Examples-----
Input
3 1
ioi
1 1 i n

Output
noi
Input
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g

Output
gaaak


-----Note-----

For the second example:

After the first operation, the string is wxxak.

After the second operation, the string is waaak.

After the third operation, the string is gaaak.

Difficulty: EASY

Solutions:
(n, m) = list(map(int, input().split()))
s = input()
for i in range(m):
	(l, r, c, c2) = input().split()
	(l, r) = (int(l), int(r))
	for j in range(l - 1, r):
		if s[j] == c:
			s = s[:j] + c2 + s[j + 1:]
print(s)


from itertools import *
(n, m) = list(map(int, input().split()))
s = input()
for _ in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	s = s[:l - 1] + s[l - 1:r].replace(c1, c2) + s[r:]
print(s)


(num1, num2) = map(int, input().split())
list1 = list(input())
for _ in range(int(num2)):
	(l, r, c1, c2) = input().split()
	temb = int(l) - 1
	for x in range(int(l) - 1, int(r)):
		if list1[int(temb)] == c1:
			list1[int(temb)] = c2
		temb += 1
print(''.join(list1))


(n, k) = list(map(int, input().split()))
s = input()
for i in range(k):
	p = ''
	(l, r, c1, c2) = input().split()
	for j in range(n):
		if j in range(int(l) - 1, int(r)):
			if s[j] == c1:
				p += c2
			else:
				p += s[j]
		else:
			p += s[j]
	s = p
print(p)


def chan(y, lrc):
	h = []
	for x in y:
		h.append(x)
	l = int(lrc[0]) - 1
	r = int(lrc[1]) - 1
	for x in range(r - l + 1):
		if h[l] == lrc[2]:
			h[l] = lrc[3]
		l += 1
	return ''.join(h)

def run():
	indicaciones = input().strip()
	ind = indicaciones.split(' ')
	cadena = input()
	new = cadena
	for x in range(int(ind[1])):
		tmp = input().strip()
		lrc = tmp.split(' ')
		new = chan(new, lrc)
	print(new)
run()


(n, a) = map(int, input().split())
string = input()
for i in range(a):
	(l, r, c1, c2) = input().split()
	string = string[:int(l) - 1] + string[int(l) - 1:int(r)].replace(c1, c2) + string[int(r):]
print(string)


nmStr = input()
nm = nmStr.split()
n = int(nm[0])
m = int(nm[1])
s = input()
for i in range(m):
	lrcStr = input()
	lrc = lrcStr.split()
	l = int(lrc[0])
	r = int(lrc[1])
	c1 = lrc[2][0]
	c2 = lrc[3][0]
	for j in range(l - 1, r):
		if s[j] == c1:
			s = s[:j] + c2 + s[j + 1:]
print(s)


(z, zz, dgraphs) = (input, lambda : list(map(int, z().split())), {})
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, m) = zz()
l = z()
for _ in range(m):
	(a, b, c, d) = z().split()
	a = int(a) - 1
	b = int(b) - 1
	for i in l[a:b + 1]:
		if i == c:
			x = d
			l = l[:a] + x + l[a + 1:]
		a += 1
print(l)


(n, m) = map(int, input().split())
s = input()
li = []
slist = []
for i in s:
	slist.append(i)
for i in range(m):
	a = input().split()
	li.append(a)
for i in range(m):
	for j in range(int(li[i][0]) - 1, int(li[i][1])):
		if slist[j] == li[i][2]:
			slist[j] = li[i][3]
s = ''
for i in slist:
	s += i
print(s)


(N, K) = map(int, input().split())
string = input()
for _ in range(K):
	(fr, to, c1, c2) = input().split()
	(fr, to) = (int(fr), int(to))
	(fr, to) = (fr - 1, to - 1)
	for i in range(fr, to + 1):
		if string[i] == c1:
			string = string[:i] + c2 + string[i + 1:]
print(string)


(n, m) = map(int, input().split())
s = input()
op = [tuple(input().split()) for _ in range(m)]
for o in op:
	l = int(o[0]) - 1
	r = int(o[1]) - 1
	for i in range(l, r + 1):
		if s[i] == o[2]:
			s = s[:i] + o[3] + s[i + 1:]
print(s)


def main():
	s = input()
	s = list(s.split())
	n = int(s[0])
	m = int(s[1])
	s = input()
	a = []
	for i in s:
		a.append(i)
	for i in range(m):
		s = input()
		s = list(s.split())
		for i in range(int(s[0]) - 1, int(s[1])):
			if a[i] == s[2]:
				a[i] = s[3]
	s = ''
	for i in range(n):
		s = s + a[i]
	print(s)
main()


(n, m) = map(int, input().split())
s = input()
for i in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l) - 1, int(r))
	s = s[:l] + s[l:r].replace(c1, c2) + s[r:]
print(s)


(n, m) = map(int, input().split())
s = input()
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	l -= 1
	r -= 1
	j = l
	while j <= r:
		if s[j] == c1:
			s = s[:j] + c2 + s[j + 1:]
		j += 1
print(s)


(n, m) = [int(i) for i in input().split(' ')]
palavr = input()
palavra = [i for i in palavr]
while m > 0:
	(i1, i2, la, nl) = [str(s) for s in input().split(' ')]
	i1 = int(i1)
	i2 = int(i2)
	for i in range(i1 - 1, i2, 1):
		if palavra[i] == la:
			palavra[i] = nl
	m -= 1
print(''.join(palavra))


(n, m) = map(int, input().split())
a = list(input())
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	for j in range(int(l) - 1, int(r)):
		if a[j] == c1:
			a[j] = c2
print(''.join(a))


(n, k) = map(int, input().split())
s = input()
s = list(s)
for i in range(k):
	(l, r, x, y) = input().split()
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if s[i] == x:
			s[i] = y
print(''.join(s))


(n, m) = (int(i) for i in input().split())
S = list(input())
for _ in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l) - 1
	r = int(r) - 1
	for i in range(l, r + 1):
		if S[i] == c1:
			S[i] = c2
print(''.join(S))


(n, m) = list(map(int, input().split()))
s = input()
ss = list(s)
result = ''
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	for i in range(int(l) - 1, int(r)):
		if ss[i] == c1:
			ss[i] = c2
result = result.join(ss)
print(result)


(n, m) = [int(i) for i in input().split()]
s = list(str(input()))
for k in range(m):
	(l, r, c1, c2) = [str(i) for i in input().split()]
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if s[i] == c1:
			s[i] = c2
s = ''.join(s)
print(s)


(n, m) = list(map(int, input().split()))
s = list(input())
for i in range(m):
	(l, r, c1, c2) = input().split()
	if l == r:
		if s[int(l) - 1] == c1:
			s[int(l) - 1] = c2
	else:
		s = list(''.join(s[:int(l) - 1]) + ''.join(s[int(l) - 1:int(r)]).replace(c1, c2) + ''.join(s[int(r):]))
print(''.join(s))


n = list(map(int, input().split()))
stri = list(input())
for _ in range(0, n[1]):
	take = input().split()
	(take[0], take[1]) = (int(take[0]), int(take[1]))
	for i in range(take[0] - 1, take[1]):
		if stri[i] == take[2]:
			stri[i] = take[3]
print(''.join(stri))


(a, b) = input().split()
c = input()
for j in range(int(b)):
	(l, r, c1, c2) = input().split()
	for i in range(int(l) - 1, int(r)):
		if c[i] == c1:
			c = c[:i] + c2 + c[i + 1:]
print(c)


n = input().split()
s = input()
for i in range(int(n[1])):
	j = list(input().split())
	l = []
	for o in range(int(j[0]), int(j[1]) + 1):
		if s[o - 1] == j[2]:
			l.append(int(o - 1))
	h = s
	s = []
	for p in range(int(n[0])):
		if l.count(p) == 1:
			s.append(j[3])
		else:
			s.append(h[p])
print(*s, sep='')


(n, m) = [int(x) for x in input().split()]
s = [x for x in input()]
for _ in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for i in range(l - 1, r):
		if s[i] == c1:
			s[i] = c2
print(''.join(s))


(n, m) = map(int, input().split())
s = str(input())
l = list(s)
for i in range(m):
	arr = list(map(str, input().split()))
	l1 = int(arr[0])
	l2 = int(arr[1])
	for j in range(l1 - 1, l2):
		if l[j] == arr[2]:
			l[j] = arr[3]
ans = ''
for i in range(n):
	ans += l[i]
print(ans)


(n, m) = map(int, input().split())
a = list(input())
for i in range(m):
	(s, d, c1, c2) = input().split()
	s = int(s)
	d = int(d)
	for j in range(s - 1, d):
		if a[j] == c1:
			a[j] = c2
print(''.join(a))


(n, m) = map(int, input().split())
word = list(input())
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for w in range(l - 1, r):
		if word[w] == c1:
			word[w] = str(c2)
print(''.join(word))


(n, k) = [int(x) for x in input().split()]
a = input()
for i in range(k):
	(r, l, c, d) = [x for x in input().split()]
	r = int(r) - 1
	l = int(l)
	a = a[0:r] + a[r:l].replace(c, d) + a[l:]
print(a)


(n, m) = list(map(int, input().split()))
st = list(input().strip())
for i in range(m):
	(ls, rs, c1, c2) = list(input().split())
	l = int(ls) - 1
	r = int(rs) - 1
	for j in range(l, r + 1):
		if st[j] == c1:
			st[j] = c2
print(''.join(st))


l = list(map(int, input().split()))
n = l[0]
m = l[1]
s = input()
for i in range(m):
	p = list(map(str, input().split()))
	l = int(p[0])
	r = int(p[1])
	c1 = p[2]
	c2 = p[3]
	for j in range(l - 1, r):
		if s[j] == c1:
			s = s[:j] + c2 + s[j + 1:]
print(s)


(n, m) = map(int, input().split())
s = input()
list = [s[i] for i in range(n)]
while m > 0:
	line = input().split()
	(l, r) = (int(line[0]), int(line[1]))
	(x, y) = (line[2], line[3])
	for j in range(l - 1, r):
		if list[j] == x:
			list[j] = y
	m -= 1
print(''.join(list))


(n, m) = map(int, input().split())
s = str(input())
ll = list(s)
for i in range(m):
	(l, r, c1, c2) = input().split()
	l1 = int(l)
	r1 = int(r)
	if l1 == r1:
		for i in range(l1 - 1, r1):
			if c1 == ll[i]:
				ll[i] = c2
	else:
		for i in range(l1 - 1, r1):
			if c1 == ll[i]:
				ll[i] = c2
print(''.join(ll))


(a, b) = list(map(int, input().split()))
lst = list(input())
for i in range(b):
	(ls, rs, c1, c2) = list(input().split())
	(l, r) = (int(ls) - 1, int(rs) - 1)
	for j in range(l, r + 1):
		if lst[j] == c1:
			lst[j] = c2
print(''.join(lst))


(_, m) = map(int, input().split())
a = input()
for _ in [0] * m:
	(l, r, b, c) = input().split()
	l = int(l) - 1
	r = int(r)
	a = a[:l] + a[l:r].replace(b, c) + a[r:]
print(a)


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	(l1, l2, c1, c2) = map(str, input().split())
	l1 = int(l1)
	l2 = int(l2)
	for i in range(l1, l2 + 1):
		if s[i - 1] == c1:
			s[i - 1] = c2
print(''.join(s))


(n, m) = map(int, input().split())
s = list(input().strip())
while m > 0:
	m -= 1
	(l, r, c1, c2) = input().split(' ')
	l = int(l) - 1
	r = int(r) - 1
	while l <= r:
		if s[l] == c1:
			s[l] = c2
		l += 1
print(''.join(s))


def Scarborough(n, m, s, ls):
	s = list(s)
	for i in range(m):
		for j in range(int(ls[i][0]) - 1, int(ls[i][1])):
			if s[j] == ls[i][2]:
				s[j] = ls[i][3]
	return s
(n, m) = input().split()
n = int(n)
m = int(m)
s = str(input())
ls = [input().split() for i in range(m)]
print(''.join(map(str, Scarborough(n, m, s, ls))))


import sys
Input = sys.stdin.readline
(a, b) = map(int, input().split())
s = list(map(str, input()))
for _ in range(b):
	(c, d, e, f) = input().split()
	c = int(c) - 1
	d = int(d)
	for j in range(c, d):
		if s[j] == e:
			s[j] = f
print(*s, sep='')


(n, m) = [int(x) for x in input().split(' ')]
st = input()
lis = []
for i in st:
	lis.append(i)
l = []
for i in range(m):
	l1 = [x for x in input().split(' ')]
	l.append(l1)
for i in range(m):
	(p, q, r, s) = l[i]
	for j in range(int(p) - 1, int(q)):
		if lis[j] == r:
			lis[j] = s
for i in lis:
	print(i, end='')


(n, m) = map(int, input().split())
s = input()
for _ in range(m):
	(l, r, c1, c2) = input().split()
	for i in range(int(l) - 1, int(r), 1):
		if s[i] == c1:
			s = s[0:i] + c2 + s[i + 1:len(s)]
print(s, end='')


import time

def guessStringAftOperations(oper, origS, operList):
	nstr = origS
	for x in range(oper):
		nstr = convertStringInto(nstr, operList[x][0], operList[x][1], operList[x][2], operList[x][3])
	return nstr

def convertStringInto(st, iniPos, endPos, fromChar, toChar):
	nSt = ''
	for pos in range(len(st)):
		if st[pos] == fromChar and pos in range(int(iniPos) - 1, int(endPos)):
			nSt += toChar
		else:
			nSt += st[pos]
	return nSt

def solve():
	(lenS, oper) = [int(x) for x in input().split()]
	origS = input()
	operList = []
	for x in range(oper):
		operList.append(list(map(str, input().split())))
	print(guessStringAftOperations(oper, origS, operList))
solve()


(n, m) = map(int, input().split())
l = list(map(str, input().strip()))
s = ''
for _ in range(m):
	(le, r, c1, c2) = input().split()
	a = int(le)
	b = int(r)
	for i in range(a - 1, b):
		if l[i] == c1:
			l[i] = c2
s = s + ''.join(l)
print(s)


(n, m) = map(int, input().split(' '))
s = list(map(str, input().strip()))
for i in range(m):
	(l, r, c, d) = map(str, input().split(' '))
	for j in range(int(l), int(r) + 1):
		if s[j - 1] == c:
			s[j - 1] = d
print(*s, sep='')


(x, y) = [int(i) for i in input().split()]
s = input()
o = []
for i in range(x):
	o.append(s[i])
for i in range(y):
	p = input().split()
	l = int(p[0])
	r = int(p[1])
	c1 = p[2]
	c2 = p[3]
	if l != r:
		for i in range(l - 1, r):
			if o[i] == c1:
				o.pop(i)
				o.insert(i, c2)
	elif o[l - 1] == c1:
		o.pop(l - 1)
		o.insert(l - 1, c2)
print(''.join(o))


(n, m) = map(int, input().split())
line = list(input())
for i in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for j in range(l - 1, r):
		el = line[j]
		if el == c1:
			line[j] = c2
print(''.join(line))


R = lambda : list(map(int, input().split()))
(n, m) = R()
s = list(input())
for x in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l) - 1, int(r) - 1)
	while l <= r:
		if str(s[l]) == c1:
			s[l] = c2
		l += 1
print(''.join(s))


(n, t) = list(map(int, input().split()))
s1 = input()
s = []
for i in range(n):
	s.append(s1[i])
while t:
	arr = list(map(str, input().split()))
	l = int(arr[0])
	r = int(arr[1])
	c1 = arr[2]
	c2 = arr[3]
	for i in range(l - 1, r):
		if s[i] == c1:
			s[i] = c2
	t = t - 1
res = ''
for i in range(n):
	res = res + str(s[i])
print(res)


l = input().split()
n = int(l[0])
m = int(l[1])
s = input()
s = list(s)
for i in range(m):
	x = input().split()
	l = int(x[0])
	r = int(x[1])
	c1 = x[2]
	c2 = x[3]
	for j in range(l - 1, r):
		if s[j] == c1:
			s[j] = c2
t = ''
for i in range(len(s)):
	t += s[i]
print(t)


a = list(map(int, input('').strip().split()))
b = input('').strip().split()
target = []
for i in b[0]:
	target.append(i)
for _ in range(a[1]):
	c = list(map(str, input('').strip().split()))
	(start, end) = (int(c[0]) - 1, int(c[1]))
	for j in range(start, end):
		if c[2] == target[j]:
			target[j] = c[3]
answer = ''.join(target)
print(answer)


(n, m) = map(int, input().split())
s = input()
lst = list(s)
res = ''
for _ in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	for i in range(l, r + 1):
		if lst[i - 1] == c1:
			lst[i - 1] = c2
res = ''.join(lst)
print(res)


def main():
	(n, m) = map(int, input().split())
	s = input()
	s = list(s)
	for i in range(0, m):
		(l, r, c1, c2) = input().split(' ')
		l = int(l)
		r = int(r)
		l -= 1
		r -= 1
		for j in range(l, r + 1):
			if s[j] == c1:
				s[j] = c2
	s = ''.join((str(l) for l in s))
	print(s)
main()


(n, m) = map(int, input().strip().split()[:2])
k = list(input().strip()[:n])
for z in range(m):
	(l, r, x, y) = input().strip().split()[:4]
	for q in range(int(l) - 1, int(r)):
		if k[q] == x:
			k[q] = y
print(''.join(map(str, k)))


input1 = input()
input_list = input1.split(' ')
n = int(input_list[0].strip())
m = int(input_list[1].strip())
string = input()
string = list(string)
for i in range(0, m):
	input1 = input()
	input_list = input1.split(' ')
	l = int(input_list[0].strip())
	r = int(input_list[1].strip())
	c1 = input_list[2].strip()
	c2 = input_list[3].strip()
	for j in range(l - 1, r):
		if string[j] == c1:
			string[j] = c2
string = ''.join(string)
print(string)


(n, m) = map(int, input().split())
word = list(input())
lst_cmd = []
for i in range(m):
	cmd = input().split()
	for j in range(int(cmd[0]) - 1, int(cmd[1])):
		if word[j] != cmd[2]:
			pass
		else:
			word[j] = cmd[3]
print(''.join(word))


(a, b) = map(int, input().split())
s = [str(i) for i in input()][:a]
for i in range(b):
	(l, r, c_1, c_2) = input().split()
	(l, r) = (int(l), int(r))
	for index in range(l - 1, r):
		if s[index] == c_1:
			s[index] = c_2
print(''.join(s))


R = lambda : map(int, input().split())
(n, m) = R()
str = input()
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	cstr = str[l - 1:r].replace(c1, c2)
	cstr = str[:l - 1] + cstr + str[r:]
	str = cstr
print(cstr)


i = list(map(int, input().split()))
letras = str(input())
palabra = []
for k in range(i[0]):
	palabra.append(letras[k])
for k in range(i[1]):
	comando = input().split()
	for j in range(int(comando[0]) - 1, int(comando[1])):
		if palabra[j] == comando[2]:
			palabra[j] = comando[3]
final = ''
for k in range(i[0]):
	final += palabra[k]
print(final)


(n, m) = (int(v) for v in input().split())
x = [v for v in input().strip('\n\r')]
ans = ''
for i in range(m):
	(l, r, c_1, c_2) = (v for v in input().split())
	for j in range(int(l) - 1, int(r)):
		if x[j] == c_1:
			x[j] = c_2
		else:
			pass
for k in range(len(x)):
	ans += x[k]
print(ans)


def inp(func=int):
	tmp = list(map(func, input().split()))
	return tmp if len(tmp) > 1 else tmp[0]
(n, m) = inp()
s = input()
for i in range(m):
	(i, r, c1, c2) = input().split()
	i = int(i) - 1
	r = int(r)
	s = s[:i] + s[i:r].replace(c1, c2) + s[r:]
print(s)


(length, ops) = list(map(int, input().split()))
string = list(input())
for i in range(ops):
	(start, stop, original, new) = list(input().split())
	start = int(start)
	stop = int(stop)
	for j in range(start, stop + 1):
		if string[j - 1] == original:
			string[j - 1] = new
print(''.join(string))


s = list(map(int, input().split()))
first = input()
third = []
for i in range(len(first)):
	third.append(first[i])
for i in range(s[1]):
	second = list(map(str, input().split()))
	for j in range(int(second[0]) - 1, int(second[1])):
		if third[j] == second[2]:
			third[j] = second[3]
print(*third, sep='')


import sys
sys.setrecursionlimit(100000000)
(N, M) = map(int, input().split())
line = [x for x in input()]
for t in range(M):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if line[i] == c1:
			line[i] = c2
print(''.join(line), flush=True)


(n, k) = map(int, input().split())
s1 = list(input())
s2 = ''
for i in range(k):
	s = input().split()
	s[0] = int(s[0])
	s[1] = int(s[1])
	for i in range(s[0], s[1] + 1):
		if s[2] == s1[i - 1]:
			s1[i - 1] = s[3]
	s2 = ''.join(s1)
print(s2)


(n, m) = input().split()
n = int(n)
m = int(m)
s = input()
for i in range(0, m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for j in range(l - 1, r):
		if s[j] == c1:
			s = s[:j] + c2 + s[j + 1:]
print(s)


a = list(map(int, input().split()))
b = list(input())
c = []
for x in range(a[1]):
	c.append(input().split())
for x in range(a[1]):
	for z in range(int(c[x][0]) - 1, int(c[x][1])):
		if c[x][2] == b[z]:
			b[z] = c[x][3]
[print(b[x], end='') for x in range(a[0])]


(n, k) = map(int, input().split())
a = list(input())
for i in range(k):
	b = input().split()
	for j in range(int(b[0]) - 1, int(b[1])):
		if a[j] == b[2]:
			a[j] = b[3]
c = ''.join(a)
print(c)


(m, n) = map(int, input().split())
k = list(input())
for i in range(n):
	(a1, a2, c, d) = input().split()
	for j in range(int(a1) - 1, int(a2)):
		if k[j] == c:
			k[j] = d
print(''.join(k))


(n, k) = map(int, input().split())
s = input()
for i in range(k):
	(x, y, c, d) = input().split()
	a = int(x)
	b = int(y)
	if b < n:
		s = s[:a - 1] + s[a - 1:b].replace(c, d) + s[b:]
	else:
		s = s[:a - 1] + s[a - 1:b].replace(c, d)
print(s)


(length, operations) = map(int, input().split())
string = input()
lst = []
for i in string:
	lst.append(i)
for n in range(operations):
	(start, end, letter1, letter2) = [x for x in input().split()]
	start1 = int(start) - 1
	end1 = int(end) - 1
	for i in range(start1, end1 + 1):
		if lst[i] == letter1:
			lst[i] = letter2
print(''.join(lst))


def query(s, l, r, c1, c2):
	for i in range(l - 1, r):
		s[i] = c2 if s[i] == c1 else s[i]
	return s
(n, m) = input().split(' ')
(n, m) = (int(n), int(m))
s = list(input())
for i in range(m):
	(l, r, c1, c2) = input().split(' ')
	(l, r) = (int(l), int(r))
	s = query(s, l, r, c1, c2)
print(''.join(s))


(n, t) = map(int, input().split())
way = list(input())
for i in range(t):
	arr = list(input().split())
	for a in range(1, len(way) + 1):
		if a >= int(arr[0]) and a <= int(arr[1]) and (way[a - 1] == arr[2]):
			way[a - 1] = way[a - 1].replace(way[a - 1], arr[3])
print(''.join(way))


(n, m) = list(map(int, input().split()))
s = input()
s_li = list(s)
for i in range(m):
	inp = input().split()
	(l, r, c1, c2) = (int(inp[0]), int(inp[1]), inp[2], inp[3])
	tmp = s_li[l - 1:r]
	for j in range(len(tmp)):
		if tmp[j] == c1:
			tmp[j] = c2
	s_li[l - 1:r] = tmp
print(''.join(s_li))


n = [int(x) for x in input().split()]
s = [x for x in input()]
for i in range(n[1]):
	p = [x for x in input().split()]
	for j in range(int(p[0]) - 1, int(p[1])):
		if s[j] == p[2]:
			s[j] = p[3]
for e in s:
	print(e, end='')


(a, b) = map(int, input().split())
l = input()
f = []
for i in l:
	f.append(i)
for i in range(b):
	(a1, a2, a3, a4) = map(str, input().split())
	a1 = int(a1)
	a2 = int(a2)
	for i in range(a1 - 1, a2):
		if f[i] == a3:
			f[i] = a4
for i in f:
	print(i, end='')


x = input()
s = input()
x = x.split()
z = []
k = []
for i in s:
	k.append(i)
for i in range(int(x[1])):
	z.append(input())
	z[i] = z[i].split()
	if int(z[i][0]) == int(z[i][1]):
		if k[int(z[i][0]) - 1] == z[i][2]:
			k[int(z[i][0]) - 1] = z[i][3]
	else:
		for j in range(int(z[i][0]) - 1, int(z[i][1])):
			if k[j] == z[i][2]:
				k[j] = z[i][3]
s = ''
for i in k:
	s += i
print(s)


(n, m) = map(int, input().split())
s = list(input())
for _ in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for i in range(l - 1, r):
		if s[i] == c1:
			s[i] = c2
print(*s, sep='')


(n, m) = map(int, input().split())
A = input()
for _ in range(m):
	(l, r, c_1, c_2) = input().split()
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if A[i] == c_1:
			A = A[:i] + c_2 + A[i + 1:]
print(A)


def main():
	(n, m) = map(int, input().split())
	s = list(input())
	for i in range(m):
		(l, r, c1, c2) = input().split()
		l = int(l)
		r = int(r)
		for i in range(l - 1, r):
			if s[i] == c1:
				s[i] = c2
	print(''.join(s))
try:
	main()
except KeyboardInterrupt:
	pass


a = list(map(int, input().split()))
n = a[0]
m = a[1]
s = input()
for i in range(m):
	a = input().split()
	new_s = s[0:int(a[0]) - 1]
	for j in range(int(a[0]) - 1, int(a[1])):
		if s[j] == a[2]:
			new_s += a[3]
		else:
			new_s += s[j]
	new_s += s[int(a[1]):]
	s = new_s
print(s)


(n, m) = map(int, input().split())
string = input()
for _ in range(m):
	lst = input().split()
	x = int(lst[0]) - 1
	y = int(lst[1]) - 1
	string = string[:x] + string[x:y + 1].replace(lst[2], lst[3]) + string[y + 1:]
print(string)


def main():
	(n, m) = map(int, input().split())
	s = input()
	for _ in range(m):
		(l, r, c1, c2) = input().split()
		(l, r) = (int(l), int(r))
		s = s[:l - 1] + s[l - 1:r].replace(c1, c2) + s[r:]
	print(s)
main()


a = input().split(' ')
a = [int(i) for i in a]
s = input()
w = []
for i in s:
	w.append(i)
for _ in range(a[1]):
	q = input().split(' ')
	for i in range(int(q[0]) - 1, int(q[1])):
		if w[i] == q[2]:
			w[i] = q[3]
for i in w:
	print(i, end='')


(n, m) = [int(i) for i in input().split()]
word = input()
for x in range(m):
	(l, r, c1, c2) = [i for i in input().split()]
	for y in range(int(l) - 1, int(r)):
		if word[y] == c1:
			word = word[:y] + c2 + word[y + 1:]
print(word)


import sys
sys.setrecursionlimit(100000000)

def iin():
	return int(input())

def impin():
	return map(int, input().split())

def irrin():
	return [int(x) for x in input().split()]

def imrin(n):
	return [int(input()) for _ in range(n)]
(n, m) = impin()
s = [x for x in input()]
for _ in range(m):
	(l, r, c1, c2) = input().split()
	for i in range(int(l) - 1, int(r)):
		if s[i] == c1:
			s[i] = c2
print(''.join(s))


(m, n) = tuple(input().split())
s = input()
l = []
for i in s:
	l.append(i)
for i in range(int(n)):
	s = input().split()
	for j in range(int(s[0]) - 1, int(s[1])):
		if l[j] == s[2]:
			l.insert(j, s[3])
			l.pop(j + 1)
print(''.join(l))


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	a = input().split()
	j = int(a[0]) - 1
	while j <= int(a[1]) - 1:
		if s[j] == a[2]:
			s[j] = a[3]
		j += 1
print(''.join(s))


ps = input()
ps = ps.split()
n = int(ps[0])
m = int(ps[1])
st = input()
op = []
for i in range(m):
	x = []
	ak = input().split()
	op.append([int(ak[0]), int(ak[1]), ak[2], ak[3]])

def oper(oplist, s):
	ns = ''
	c = 0
	while c < n:
		if c >= oplist[0] - 1 and c <= oplist[1] - 1:
			if s[c] == oplist[2]:
				ns += oplist[3]
			else:
				ns += s[c]
		else:
			ns += s[c]
		c += 1
	return ns
z = st
for j in op:
	z = oper(j, z)
print(z)


(n, m) = map(int, input().split())
st = input()
st = list(st)
for i in range(m):
	(l, r, c1, c2) = input().split()
	for j in range(int(l) - 1, int(r)):
		if st[j] == c1:
			st[j] = c2
for i in range(len(st)):
	print(st[i], end='')


(n, m) = map(int, input().split())
s = input()
sl = ['.'] + [i for i in s]
for _ in range(m):
	(l, r, c1, c2) = input().split(' ')
	l = int(l)
	r = int(r)
	for i in range(l, r + 1):
		if sl[i] == c1:
			sl[i] = c2
ans = ''
for i in sl:
	ans += i
print(ans[1:])


def apply(smstr, start, end, letter_fr, letter_to):
	begin = smstr[:start - 1]
	finish = smstr[end:]
	to_edit = smstr[start - 1:end]
	if start == end:
		to_edit = smstr[start - 1]
	return '{}{}{}'.format(begin, to_edit.replace(letter_fr, letter_to), finish)

def main():
	buff = input().split()
	(n, m) = (int(buff[0]), int(buff[1]))
	n += 1
	smstr = input()
	commands = []
	for x in range(m):
		buff = input().split()
		commands.append((int(buff[0]), int(buff[1]), buff[2], buff[3]))
	for x in commands:
		smstr = apply(smstr, *x)
	return smstr
print(main())


(n, m) = input().split()
name = [x for x in input()]
for i in range(int(m)):
	(a, b, x, y) = input().split()
	for index in range(int(a) - 1, int(b)):
		if name[index] == x:
			name[index] = y
print(''.join(name))


(n, m) = tuple(map(int, input().split()))
s = list(input())
for i in range(m):
	(r, l, c1, c2) = tuple(input().split())
	for j in range(int(r) - 1, int(l)):
		if s[j] == c1:
			s[j] = c2
print(''.join(s))


(n, m) = map(int, input().split())
s = input()
s = list(s)
new = ''
for _ in range(m):
	List = list(map(str, input().split()))
	for i in range(int(List[0]) - 1, int(List[1])):
		if s[i] == List[2]:
			s[i] = List[3]
new = new + ''.join(s)
print(new)


(n, k) = map(int, input().split())
s = list(input())
for i in range(k):
	(l, r, c1, c2) = map(str, input().split())
	for j in range(int(l) - 1, int(r)):
		if s[j] == c1:
			s[j] = c2
		else:
			continue
print(''.join(s))


import sys, math
input = sys.stdin.readline
L = lambda : list(map(int, input().split().strip()))
M = lambda : map(int, input().split())
(n, q) = M()
s = ['o'] + list(input().strip())
for i in range(q):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for j in range(l, r + 1):
		if s[j] == c1:
			s[j] = c2
s = s[1:]
print(*s, sep='')


(n, m) = [int(i) for i in input().split()]
a = input()
for i in range(m):
	h = input()
	h = h.split()
	h[0] = int(h[0])
	h[1] = int(h[1])
	l = h[0] - 1
	r = h[1] - 1
	c1 = h[2]
	c2 = h[3]
	a = a[:l] + a[l:r + 1].replace(c1, c2) + a[r + 1:]
print(a)


def get_int(string, n):
	i = 0
	j = 0
	k = 0
	for s in string:
		k += 1
	for s in string:
		if i == n - 1:
			break
		if s == ' ':
			i += 1
		j += 1
	i = 0
	while j < k:
		if string[j] == ' ':
			break
		i = 10 * i + int(string[j])
		j += 1
	return i

def get_str(string, n):
	i = 0
	j = 0
	k = 0
	for s in string:
		k += 1
	for s in string:
		if i == n - 1:
			break
		if s == ' ':
			i += 1
		j += 1
	char = ''
	while j < k:
		if string[j] == ' ':
			break
		char += string[j]
		j += 1
	return char
x = input()
n = get_int(x, 1)
m = get_int(x, 2)
string = input()
strin = []
for i in string:
	strin.append(i)
for i in range(0, m):
	y = input()
	l = get_int(y, 1)
	r = get_int(y, 2)
	c1 = get_str(y, 3)
	c2 = get_str(y, 4)
	for k in range(l - 1, r):
		if strin[k] == c1:
			strin[k] = c2
string = ''.join(strin)
print(string)


l = list(map(int, input().split()))
st = input()
l1 = [str(i) for i in st]
for _ in range(l[1]):
	l2 = list(input().split())
	for j in range(int(l2[0]) - 1, int(l2[1])):
		if l1[j] == l2[2]:
			l1[j] = l2[3]
print(*l1, sep='')


x = [int(i) for i in input().split()]
(n, m) = (x[0], x[1])
s = input()
for i in range(m):
	(a, b, c, d) = input().split()
	for i in range(int(a) - 1, int(b)):
		if s[i] == c:
			s = s[0:i] + d + s[i + 1:]
print(s)


p1 = input()
s = list(input())
m = list()
k = list()
l = list()
j = p1.index(' ')
m = int(p1[j:])
while m > 0:
	p2 = input()
	j = p2.index(' ')
	k = int(p2[:j])
	p2 = p2[j + 1:]
	j = p2.index(' ')
	l = int(p2[:j])
	p2 = p2[j + 1:]
	j = k - 1
	p2 = list(p2)
	for i in s[k - 1:l]:
		if i == p2[0]:
			s[j] = p2[2]
		j += 1
	m = m - 1
for i in s:
	print(i, end='')


nums = [int(i) for i in input().split()]
string = input()
temp = list(string)
for x in range(nums[1]):
	entries = [i for i in input().split()]
	entries[0] = int(entries[0]) - 1
	entries[1] = int(entries[1]) - 1
	for y in range(int(entries[0]), int(entries[1]) + 1):
		if temp[y] == entries[2]:
			temp[y] = entries[3]
print(''.join(temp))


entrada = str(input())
entrada = [int(x) for x in entrada.split()]
n = entrada[0]
m = entrada[1]
s = str(input())
s_as_list = list(s)
for i in range(m):
	entrada1 = str(input())
	parameters = entrada1.split()
	(l, r, c1, c2) = (int(parameters[0]) - 1, int(parameters[1]), parameters[2], parameters[3])
	for j in range(l, r):
		if s_as_list[j] == c1:
			s_as_list[j] = c2
ans = ''.join(s_as_list)
print(ans)


(n, m) = map(int, input().split())
s = input()
lrc1c2 = [input().split() for _ in range(m)]
ans = list(s)
for i in range(m):
	li = int(lrc1c2[i][0]) - 1
	ri = int(lrc1c2[i][1])
	for j in range(li, ri):
		if ans[j] == lrc1c2[i][2]:
			ans[j] = lrc1c2[i][3]
print(''.join(ans))


n = input().split()
s = list(input())
for i in range(int(n[1])):
	c = input().split()
	for j in range(int(c[0]) - 1, int(c[1])):
		if s[j] == c[2]:
			s[j] = c[3]
t = ''
for i in range(int(n[0])):
	t += s[i]
print(t)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
st1 = input()
l = []
for i in st1:
	l.append(i)
for i in range(m):
	k = [str(x) for x in stdin.readline().split()]
	for y in range(int(k[0]) - 1, int(k[1])):
		if l[y] == k[2]:
			l[y] = k[3]
		else:
			continue
for i in l:
	stdout.write(i)


(a, b) = map(int, input().split())
x = list(input())
for i in range(b):
	(l, r, c1, c2) = map(str, input().split())
	for i in range(int(l) - 1, int(r)):
		if x[i] == c1:
			x[i] = c2
print(''.join(x))


(x, y) = map(int, input().split())
b = list(input())
for i in range(y):
	l = list(input().split())
	for j in range(int(l[0]) - 1, int(l[1])):
		if b[j] == l[2]:
			b[j] = l[3]
for i in b:
	print(i, end='')


(n, m) = input().split()
n = int(n)
m = int(m)
row = input()
for i in range(0, m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for j in range(l - 1, r):
		if row[j] == c1:
			res = list(row)
			res[j] = c2
			row = ''
			for item in res:
				row += item
print(row)


(n, m) = list(map(int, input().split()))
string = list(input())
tasks = [input().split() for _ in range(m)]
for i in range(len(tasks)):
	l = int(tasks[i][0]) - 1
	r = int(tasks[i][1])
	c1 = tasks[i][2]
	c2 = tasks[i][3]
	for j in range(l, r):
		if string[j] == c1:
			string[j] = c2
print(''.join(string))


(n, m) = map(int, input().split())
s2 = input()
s = [''] * n
for i in range(n):
	s[i] = s2[i]
lrcc = [list(map(str, input().split())) for i in range(m)]
for i in range(m):
	for j in range(int(lrcc[i][0]) - 1, int(lrcc[i][1])):
		if s[j] == lrcc[i][2]:
			s[j] = lrcc[i][3]
for i in range(n):
	print(s[i], end='')


(n, m) = map(int, input().split())
seq = [x for x in input()]
for _ in range(m):
	(*lr, c1, c2) = input().split()
	(l, r) = map(lambda x: int(x) - 1, lr)
	for i in range(l, r + 1):
		if seq[i] == c1:
			seq[i] = c2
print(''.join(seq))


(n, m) = map(int, input().split())
a = input()
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l) - 1
	r = int(r) - 1
	f = a[:l]
	for j in range(l, r + 1):
		if a[j] == c1:
			f += c2
		else:
			f += a[j]
	f += a[r + 1:]
	a = f
print(a)


(n, m) = [int(x) for x in input().split()]
s = input()
while m:
	m = m - 1
	(l, r, c1, c2) = [x for x in input().split()]
	s = s[0:int(l) - 1] + s[int(l) - 1:int(r)].replace(c1, c2) + s[int(r):n]
print(s)


(n, m) = map(int, input().split())
stringS = list(input())
counter = 0
while counter < m:
	(l, r, c1, c2) = map(str, input().split())
	l1 = int(l)
	r1 = int(r)
	for j in range(l1, r1 + 1):
		if stringS[j - 1] == c1:
			stringS[j - 1] = c2
	counter += 1
x = ''.join(stringS)
print(x)


(n, m) = map(int, input().split())
word = list(input())
for i in range(m):
	h = input().split()
	for j in range(int(h[0]) - 1, int(h[1])):
		if word[j] == h[2]:
			word[j] = h[3]
print(*word, sep='')


import sys

def readLine():
	return [int(i) for i in next(sys.stdin).strip().split()]
(n, m) = readLine()
string = [c for c in next(sys.stdin).strip()]
for _ in range(m):
	(l, r, c1, c2) = next(sys.stdin).strip().split()
	for i in range(int(l) - 1, int(r)):
		if string[i] == c1:
			string[i] = c2
print(''.join(string))


(n, m) = map(int, input().split())
s = input()
for _ in range(m):
	s1 = ''
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	if l - 1 >= 1:
		s1 += s[:l - 1]
	for i in range(l - 1, r):
		if s[i] == c1:
			s1 += c2
		else:
			s1 += s[i]
	s1 += s[r:]
	s = s1
print(s)


(n, m) = [int(i) for i in input().split()]
s = list(input().strip())
for i in range(m):
	(l, r, c1, c2) = input().split()
	for j in range(int(l) - 1, int(r)):
		if s[j] == c1:
			s[j] = c2
s1 = ''
for i in s:
	s1 += i
print(s1)


(n, m) = map(int, input().split())
s = list(input())
t = str()
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if s[i] == c1:
			s[i] = c2
for i in range(n):
	t += s[i]
print(t)


(n, m) = list(map(int, input().split()))
s = list(input())
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l) - 1
	r = int(r) - 1
	for j in range(s[l:r + 1].count(c1)):
		s[s.index(c1, l, r + 1)] = c2
print(''.join(s))


(a, b) = map(int, input().split())
z = input()
for i in range(b):
	(q, w, e, r) = map(str, input().split())
	v = z[int(q) - 1:int(w)]
	v = v.replace(e, r)
	z = z[:int(q) - 1] + v + z[int(w):]
print(z)


l = list(map(int, input().split()))
s = str(input())
for i in range(l[1]):
	m = input()
	m = m.split()
	p = s[int(m[0]) - 1:int(m[1])].replace(m[2], m[3])
	s = s[0:int(m[0]) - 1] + p + s[int(m[1]):len(s)]
print(s)


(n, q) = map(int, input().split())
s = list(input())
for _ in range(q):
	(a, b, ch1, ch2) = input().split()
	a = int(a)
	b = int(b)
	a = a - 1
	b = b - 1
	for i in range(a, b + 1):
		if s[i] == ch1:
			s[i] = ch2
print(*s, sep='')


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	a = list(input().split())
	(l, r) = (int(a[0]) - 1, int(a[1]))
	for j in range(l, r):
		if s[j] == a[2]:
			s[j] = a[3]
print(''.join(map(str, s)))


(n, m) = [int(c) for c in input().split()]
st = input()
st = list(st)
while m > 0:
	(l, r, c1, c2) = [c for c in input().split()]
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if st[i] == c1:
			st[i] = c2
	m = m - 1
print(''.join(st))


def ChangeSym(str, chanArr):
	for i in range(len(str)):
		if str[i] == chanArr[2] and i + 1 >= int(chanArr[0]) and (i + 1 <= int(chanArr[1])):
			str[i] = chanArr[3]
	return str
(n, m) = map(int, input().split())
s = list(input())
ans = ''
arr = []
for i in range(m):
	arr = list(map(str, input().split()))
	ans = ChangeSym(s, arr)
	arr = []
print(''.join(ans))


(a, b) = map(int, input().split())
cnt = 0
c = input()
x = []
for i in range(b):
	(d, e, f, g) = input().split()
	d = int(d) - 1
	e = int(e)
	c = c[:d] + c[d:e].replace(f, g) + c[e:]
print(c)


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	s1 = list(map(str, input().split()))
	for j in range(int(s1[0]) - 1, int(s1[1])):
		if s[j] == s1[2]:
			s[j] = s1[3]
print(*s, sep='')


(n, m) = map(int, input().split())
s = str(input())
for i in range(m):
	(ll, rr, c1c, c2c) = input().split()
	l = int(ll)
	r = int(rr)
	c1 = str(c1c)
	c2 = str(c2c)
	for x in range(l - 1, r):
		if s[x] == c1:
			s = s[:x] + c2 + s[x + 1:]
print(s)


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
(n, m) = q()
a = list(input())
for _ in [0] * m:
	(l, r, x, y) = qs()
	(l, r) = map(int, [l, r])
	a[l - 1:r] = [y if i == x else i for i in a[l - 1:r]]
print(*a, sep='')


L = input().split()
n = int(L[0])
m = int(L[1])
s = input()
for i in range(m):
	O = input().split()
	ini = int(O[0])
	fin = int(O[1])
	b = O[2]
	ca = O[3]
	pal = ''
	for j in range(n):
		if s[j] == b and j >= ini - 1 and (j <= fin - 1):
			pal = pal + ca
		else:
			pal = pal + s[j]
	s = pal
print(s)


(ls, ops) = [int(x) for x in input().split()]
s = input()
f = ''
for _ in range(ops):
	tmp = input().split()
	for i in range(1, len(s) + 1):
		if i >= int(tmp[0]) and i <= int(tmp[1]) and (s[i - 1] == tmp[2]):
			f = f + tmp[3]
		else:
			f = f + s[i - 1]
	s = f
	f = ''
print(s)


(n, m) = map(int, input().split())
s = list(input())
for _ in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	for i in range(len(s)):
		if i + 1 >= l and i + 1 <= r:
			if s[i] == c1:
				s[i] = c2
print(''.join(s))


(n, m) = map(int, input().split())
arr = input()
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	for i in range(int(l) - 1, int(r)):
		if arr[i] == c1:
			arr = arr[:i] + c2 + arr[i + 1:]
print(arr)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def solve():
	(N, M) = Scanner.map_int()
	S = Scanner.string()
	for _ in range(M):
		(l, r, c, d) = Scanner.string().split()
		l = int(l) - 1
		r = int(r) - 1
		T = list(S)
		for i in range(l, r + 1):
			if T[i] == c:
				T[i] = d
		S = ''.join(T)
	print(S)

def main():
	solve()
main()


(n, m) = map(int, input().split())
s = str(input())
for i in range(m):
	p = ''
	(l, r, c1, c2) = input().split()
	(l, r) = [int(l), int(r)]
	(c1, c2) = [str(c1), str(c2)]
	for j in range(n):
		if s[j] == c1 and l <= j + 1 and (r >= j + 1):
			p = p + c2
		else:
			p = p + s[j]
	s = p
print(s)


(n, m) = map(int, input().split())
s = input()
for _ in range(m):
	(a, b, c, d) = input().split()
	(a, b) = (int(a) - 1, int(b))
	s = s[:a] + s[a:b].replace(c, d) + s[b:]
print(s)


(nn, mm) = (int(x) for x in input().split(' '))
s = input()
for m in range(mm):
	(l, r, c1, c2) = input().split(' ')
	(l, r) = (int(l), int(r))
	s_upd = s[l - 1:r].replace(c1, c2)
	s = s[:l - 1] + s_upd + s[r:]
print(s)


(n, m) = map(int, input().split())
s = input()
a = []
for i in s:
	a.append(i)
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if a[i] == c1:
			a[i] = c2
for i in a:
	print(i, end='')
print()


(n, m) = map(int, input().split())
s = input()
for j in range(m):
	t = input().split()
	l = int(t[0])
	r = int(t[1])
	c1 = t[2]
	c2 = t[3]
	for i in range(l - 1, r):
		if s[i] == c1:
			s = s[:i] + c2 + s[i + 1:]
print(s)


args = [int(x) for x in input().split(' ')]
n = args[0]
m = args[1]
s = input()
for _ in range(m):
	args = input().split(' ')
	l = int(args[0])
	r = int(args[1])
	c1 = args[2]
	c2 = args[3]
	if l > 1:
		t = s[:l - 1]
	else:
		t = ''
	for i in range(l - 1, r):
		if s[i] == c1:
			t += c2
		else:
			t += s[i]
	t += s[r:]
	s = t
print(s)


(n, m) = map(int, input().split())
s = input()
string = []
for i in range(n):
	string.append(s[i])
for i in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l) - 1, int(r) - 1)
	for j in range(l, r + 1):
		if string[j] == c1:
			string[j] = c2
print(''.join(string))


s = input().split()
n = int(s[0])
m = int(s[1])
a = list(input())
i = 0
while i < m:
	s = input().split()
	l = [int(s[0]), int(s[1]), s[2], s[3]]
	while l[0] <= l[1]:
		if a[l[0] - 1] == l[2]:
			a[l[0] - 1] = l[3]
		l[0] += 1
	i += 1
print(''.join(a))


(n, k) = list(map(int, input().split()))
t = list(input())
for i in range(k):
	(l, r, c1, c2) = list(input().split())
	for j in range(int(l) - 1, int(r)):
		if t[j] == c1:
			t[j] = c2
print(''.join(t))


(n, m) = map(int, input().split())
S = input()
Line = []
for i in range(n):
	Line.append(S[i])
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	if l == r:
		if Line[l - 1] == c1:
			Line[l - 1] = c2
	else:
		for i in range(l - 1, r):
			if Line[i] == c1:
				Line[i] = c2
			else:
				pass
for i in range(n):
	print(Line[i], end='')


(m, n) = map(int, input().split())
s = input()
for i in range(n):
	(l, r, c1, c2) = input().split()
	l = int(l) - 1
	r = int(r)
	a = s[l:r]
	b = s[0:l]
	a = a.replace(c1, c2)
	c = s[r:len(s)]
	s = b + a + c
print(s)


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	(l, h, c1, c2) = input().split()[:4]
	l = int(l)
	h = int(h)
	for i in range(l - 1, h):
		if s[i] == c1:
			s[i] = c2
print(''.join(s))


(n, m) = map(int, input().split())
q = input()
s = []
for i in q:
	s.append(i)
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for j in range(l - 1, r):
		if s[j] == c1:
			s[j] = c2
for i in s:
	print(i, end='')


def transform_string(word, operations):
	letters = list(word)
	for operation in operations:
		for i in range(int(operation[0]) - 1, int(operation[1])):
			if letters[i] == operation[2]:
				letters[i] = operation[3]
	return ''.join(letters)
operations = []
(n, m) = map(int, input().split())
word = input()
for _ in range(m):
	operation = list(input().split())
	operations.append(operation)
print(transform_string(word, operations))


(n, m) = map(int, input().split())
s = input()
s = list(s)
k = []
for i in range(m):
	a = list(map(str, input().split()))
	k.append(a)
for i in range(0, m):
	c = int(k[i][0])
	d = int(k[i][1])
	for j in range(c - 1, d):
		if s[j] == k[i][2]:
			s[j] = k[i][3]
print(''.join(s))


(n, m) = map(int, input().split())
s = input()
a = [None] * n
for i in range(n):
	a[i] = s[i]
for i in range(m):
	x = input().split(' ')
	l = int(x[0])
	r = int(x[1])
	for j in range(l - 1, r):
		if a[j] == x[2]:
			a[j] = x[3]
for i in range(n):
	print(a[i], end='')


def main():
	nm = input().split()
	n = int(nm[0])
	m = int(nm[1])
	s = input()
	for i in range(m):
		lrc1c2 = input().split()
		l = int(lrc1c2[0])
		r = int(lrc1c2[1])
		c1 = lrc1c2[2]
		c2 = lrc1c2[3]
		for j in range(l - 1, r):
			if s[j] == c1:
				s = s[:j] + c2 + s[j + 1:]
	print(s)
	return s
main()


fl = input().split()
n = int(fl[0])
m = int(fl[1])
s = input()
for i in range(m):
	tl = input().split()
	l = int(tl[0])
	r = int(tl[1])
	c1 = tl[2]
	c2 = tl[3]
	s = s[0:l - 1] + s[l - 1:r].replace(c1, c2) + s[r:]
print(s)


(n, m) = map(int, input().split())
st = str(input())
s = list(st)
for i in range(m):
	x = list(input().strip().split(' '))
	l = int(x[0])
	r = int(x[1])
	c1 = x[2]
	c2 = x[3]
	for j in range(l - 1, r):
		if s[j] == c1:
			s[j] = c2
print(''.join(s))


(n, m) = map(int, input().split())
s = [0] + list(input())
for _ in range(m):
	(i, j, a, b) = input().split()
	(i, j) = (int(i), int(j))
	s[i:j + 1] = [x if x != a else b for x in s[i:j + 1]]
print(''.join(s[1:]))


(n, op) = map(int, input().split())
b = input()
a = []
for i in b:
	a += [i]
for kkk in range(op):
	(l, r, c1, c2) = map(str, input().split())
	for i in range(int(l) - 1, int(r)):
		if a[i] == c1:
			a[i] = c2
for i in a:
	print(i, end='')


a = list(map(int, input().split()))
string = input()
c = []
for i in range(a[1]):
	m = input().split()
	c.append(m)

def replace(list1, string):
	new_str = ''
	for k in range(0, int(list1[0]) - 1):
		new_str += string[k]
	for i in range(int(list1[0]) - 1, int(list1[1])):
		if string[i] == list1[2]:
			new_str += list1[3]
		else:
			new_str += string[i]
	for j in range(int(list1[1]), len(string)):
		new_str += string[j]
	return new_str
p = string
for i in range(a[1]):
	p = replace(c[i], p)
print(p)


(n, m) = map(int, input().split())
s = list(input())
l = []
for i in range(m):
	l.append(list(input().split()))
for j in range(m):
	inf = l[j][0]
	sup = l[j][1]
	for i in range(int(inf) - 1, int(sup)):
		if s[i] == l[j][2]:
			s[i] = l[j][3]
print(''.join(s))


(n, m) = map(int, input().split())
s = input()
while m:
	ss = input().split()
	l = ss[0]
	r = ss[1]
	c1 = ss[2]
	c2 = ss[3]
	for i in range(int(l) - 1, int(r)):
		if s[i] == c1:
			s = s[:i] + c2 + s[i + 1:]
	m -= 1
print(s)


(n, m) = map(int, input().split())
l = list(input())
for i in range(m):
	(a, b, c, d) = map(str, input().split())
	for i in range(int(a) - 1, int(b)):
		if l[i] == c:
			l[i] = d
print(''.join(l))


(n, m) = [int(i) for i in input().split()]
s = input()
l = n * ['']
for i in range(n):
	l[i] = s[i]
a = m * [0]
b = m * [0]
c = m * ['']
d = m * ['']
for i in range(m):
	k = input().split()
	a[i] = int(k[0]) - 1
	b[i] = int(k[1])
	c[i] = k[2]
	d[i] = k[3]
for i in range(m):
	for k in range(a[i], b[i]):
		if l[k] == c[i]:
			l[k] = d[i]
s = ''
for i in range(n):
	s = s + l[i]
print(s)


(a, b) = map(int, input().split())
c = str(input())
for _ in range(b):
	dd = str(input())
	d = dd.split(' ')
	e = str('')
	e = c[0:int(d[0]) - 1]
	f = c[int(d[0]) - 1:int(d[1])]
	f = f.replace(d[2], d[3])
	e = e + f
	e = e + c[int(d[1]):a]
	c = e
print(c)


(n, m) = map(int, input().split())
orig = input()
test = list(orig)
for _ in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for i in range(l - 1, r):
		if test[i] == c1:
			test[i] = c2
print(''.join(test))


import re
(n, m) = list(map(int, input().split()))
s = input()
for _ in range(m):
	(l, r, a, b) = input().strip().split()
	(l, r) = (int(l), int(r))
	s = s[:l - 1] + re.sub(a, b, s[l - 1:r]) + s[r:]
print(s)


import re
(n, m) = map(int, input().split())
s = input()
for i in range(0, m):
	a = list(input().split())
	s = s[:int(a[0]) - 1] + s[int(a[0]) - 1:int(a[1])].replace(a[2], a[3]) + s[int(a[1]):]
print(s)


(a, b) = input().split()
n = int(a)
m = int(b)
s = input()
for i in range(m):
	(l, r, c1, c2) = input().split()
	for i in range(n):
		if i >= int(l) - 1 and i <= int(r) - 1 and (s[i] == c1):
			s = s[:i] + c2 + s[i + 1:]
print(s)


(n, m) = list(map(int, input().split()))
x = input()
y = []
for i in range(n):
	y.append(x[i])
for _ in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for i in range(l - 1, r):
		if y[i] == c1:
			y[i] = c2
print(''.join(y))


i = input
(n, m) = map(int, i().split())
s = i()
tmp = ''
for j in range(m):
	l = [*map(str, i().split())]
	tmp += s[0:int(l[0]) - 1]
	tmp += s[int(l[0]) - 1:int(l[1])].replace(l[2], l[3], 100)
	tmp += s[int(l[1]):]
	s = tmp
	tmp = ''
print(s)


(n, m) = map(int, input().split())
s = input()
for i in range(m):
	(a, b, c, d) = input().split()
	for j in range(int(a) - 1, int(b)):
		if s[j] == c:
			s = s[:j] + d + s[j + 1:]
print(s)


from sys import stdin, stdout

def main():
	(n, m) = map(int, stdin.readline().strip().split(' '))
	s = list(stdin.readline().strip())
	for i in range(m):
		(l, r, c1, c2) = stdin.readline().strip().split(' ')
		l = int(l) - 1
		r = int(r) - 1
		for j in range(l, r + 1):
			if s[j] == c1:
				s[j] = c2
	print(''.join(s))
main()


(n, m) = map(int, input().strip().split(' '))
t = list(input())
s = ['4']
for i in t:
	s.append(str(i))
for i in range(m):
	t = list(map(str, input().strip().split(' ')))
	l = int(t[0])
	r = int(t[1])
	for j in range(l, r + 1):
		if s[j] == t[2]:
			s[j] = t[3]
for i in s:
	if i == '4':
		continue
	print(i, end='')


(n, m) = input().split()
(n, m) = (int(n), int(m))
s = input()
for i in range(m):
	p = input().split()
	(l, r) = (int(p[0]), int(p[1]))
	s = s[:l - 1] + s[l - 1:r].replace(p[2], p[3]) + s[r:]
print(s)


(n, m) = map(int, input().split())
s = str(input())
for _ in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l) - 1
	r = int(r)
	p = s[l:r]
	p = p.replace(c1, c2)
	s = s[:l] + p + s[r:]
print(s)


from sys import stdin

def main():
	(n, m) = [int(i) for i in stdin.readline().strip().split()]
	string = list(stdin.readline().strip())
	for i in range(m):
		(beg, end, find, replace) = [i for i in stdin.readline().strip().split()]
		(beg, end) = (int(beg), int(end))
		for i in range(beg - 1, end):
			if string[i] == find:
				string[i] = replace
	print(''.join(string))
main()


def read_ints():
	return [int(x) for x in input().split()]

def main():
	(_, num_ops) = read_ints()
	text = input()
	for _ in range(num_ops):
		(l, r, c1, c2) = input().split()
		(l, r) = (int(l) - 1, int(r) - 1)
		text = text[:l] + text[l:r + 1].replace(c1, c2) + text[r + 1:]
	print(text)
main()


(m, n) = map(int, input().split())
c = list(input())
for i in range(n):
	(l, r, d1, d2) = input().split()
	for j in range(int(l) - 1, int(r)):
		if c[j] == d1:
			c[j] = d2
print(''.join(c))


(x, n) = input().split(' ')
n = int(n)
s = input()
lol = s
for i in range(n):
	kek = lol
	(l, r, c1, c2) = input().split()
	l = int(l) - 1
	r = int(r) - 1
	lol = kek[:l]
	for i in range(l, r + 1):
		if kek[i] == c1:
			lol += c2
		else:
			lol += kek[i]
	lol += kek[r + 1:]
print(lol)


baris = input()
string = baris.split(' ')
n = int(string[0])
m = int(string[1])
s = input()
for i in range(0, m):
	baris = input()
	string = baris.split(' ')
	l = int(string[0])
	r = int(string[1])
	c1 = string[2]
	c2 = string[3]
	for j in range(l, r + 1):
		if s[j - 1] == c1:
			s = s[0:j - 1] + c2 + s[j:]
print(s)


s = input()
s = s.split()
s = [int(i) for i in s]
n = s[0]
m = s[1]
s = input()
x = []
x.append('blank')
for i in range(m):
	t = input()
	t = t.split()
	x.append(t)
y = []
y.append(s)
for i in range(1, m + 1):
	l = int(x[i][0]) - 1
	r = int(x[i][1]) - 1
	c1 = x[i][2]
	c2 = x[i][3]
	t = ''
	j = 0
	while j < len(s):
		if j in range(l, r + 1):
			t += y[i - 1][l:r + 1].replace(c1, c2)
			j = r
		else:
			t += y[i - 1][j]
		j += 1
	y.append(t)
p = len(y) - 1
print(y[p])


a = input() + ' '
s = input()
b = ''
A = []
for j in range(len(a)):
	if a[j] == ' ':
		A.append(int(b))
		b = ''
	else:
		b += a[j]
for i in range(A[1]):
	a1 = input() + ' '
	b1 = ''
	A1 = []
	for j in range(len(a1)):
		if a1[j] == ' ':
			A1.append(b1)
			b1 = ''
		else:
			b1 += a1[j]
	for i in range(int(A1[0]) - 1, int(A1[1])):
		if s[i] == A1[2]:
			s = s[:i] + A1[3] + s[i + 1:]
print(s)


(q, n) = input().split()
x = input()
x = list(x.strip())
for i in range(int(n)):
	m = list(input().split())
	l = int(m[0])
	r = int(m[1])
	for i in range(l - 1, r):
		if x[i] == m[2]:
			x[i] = m[3]
		if l == r:
			if x[l - 1] == m[2]:
				x[i] = m[3]
ans = ''
for i in x:
	ans = ans + i
print(ans)


(lent, tests) = map(int, input().split(' '))
inp = input()
for i in range(tests):
	(start, end, act, chn) = input().split()
	start = int(start) - 1
	end = int(end) - 1
	strr = ''
	for i in range(start, end + 1):
		if inp[i] == act:
			strr += chn
		else:
			strr += inp[i]
	inp = inp[0:start] + strr + inp[end + 1:]
print(inp)


(n, m) = map(int, input().split())
string = list(input())
for time in range(m):
	inp = input().split()
	(l, r, c1, c2) = (int(inp[0]), int(inp[1]), inp[2], inp[3])
	(l, r) = (l - 1, r - 1)
	for index in range(l, r + 1):
		if string[index] == c1:
			string[index] = c2
else:
	zzz = ''
	for i in string:
		zzz += i
	print(zzz)


(n, m) = map(int, input().split())
s = [c for c in input()]
for _ in range(m):
	(l, r, a, b) = input().split()
	l = int(l) - 1
	r = int(r)
	for i in range(l, r):
		if s[i] == a:
			s[i] = b
print(''.join(s))


(lll, n) = map(int, input().split())
s = list(input())
for i in range(n):
	(a, b, c1, c2) = input().split()
	for j in range(int(a) - 1, int(b)):
		if s[j] == c1:
			s[j] = c2
print(''.join(s))


(n, q) = map(int, input().split())
s = input()
li = [i for i in s]
for _ in range(q):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	l -= 1
	for i in range(l, r):
		if li[i] == c1:
			li[i] = c2
print(''.join(li))


(a, b) = map(int, input().split())
x = input()
arr = []
xx = []
for z in range(len(x)):
	xx.append(x[z])
for i in range(b):
	arr.append(input().split(' '))
for l in range(b):
	for s in range(int(arr[l][0]) - 1, int(arr[l][1])):
		if arr[l][2] == xx[s]:
			xx[s] = arr[l][3]
print(*xx, sep='')


(n, m) = map(int, input().split())
strng = list(input())
tasks = []
for i in range(m):
	tasks.append(list(map(str, input().split())))
for i in range(len(tasks)):
	l = int(tasks[i][0])
	r = int(tasks[i][1])
	c1 = tasks[i][2]
	c2 = tasks[i][3]
	for j in range(l - 1, r):
		if strng[j] == c1:
			strng[j] = c2
ans = ''
for i in strng:
	ans += i
print(ans)


(n, m) = map(int, input().split())
a = input()
for i in range(m):
	l = []
	l = list(map(str, input().split()))
	a = a[:int(l[0]) - 1] + a[int(l[0]) - 1:int(l[1])].replace(l[2], l[3]) + a[int(l[1]):]
print(a)


(length, times) = input().split(' ')
string = list(input())
for i in range(int(times)):
	data = input().split(' ')
	indecies = [int(x) for x in data[:2]]
	chars = data[2:]
	for x in range(indecies[0] - 1, indecies[1]):
		if string[x] == chars[0]:
			string[x] = chars[1]
print(''.join(string))


(n, m) = input().split()
string = list(input().lower())
for i in range(int(m)):
	(start, end, chara, rep) = input().split()
	for i in range(int(start) - 1, int(end)):
		if string[i] == chara:
			string[i] = rep
print(''.join(string))


(n, k) = map(int, input().split())
resht = input()
reshte = []
for char in resht:
	reshte.append(char)
for i in range(k):
	(p, t, d, f) = input().split()
	p = int(p)
	t = int(t)
	for j in range(p - 1, t):
		if reshte[j] == d:
			reshte[j] = f
output = ''
for char in reshte:
	output += char
print(output)


(n, m) = map(int, input().split())
l = list(input())
for i in range(m):
	d = list(input().split())
	d[0] = int(d[0]) - 1
	d[1] = int(d[1]) - 1
	for j in range(d[0], d[1] + 1):
		if l[j] == d[2]:
			l[j] = d[3]
print(''.join(l))


(a, b) = map(int, input().split())
x = input()
z = []
d = {}
for i in range(b):
	k = list(input().split())
	z.append(k)
for i in range(b):
	for j in range(int(z[i][0]) - 1, int(z[i][1])):
		if j in d:
			if d[j] == z[i][2]:
				d.pop(j, None)
				d[j] = z[i][3]
		elif x[j] == z[i][2]:
			d[j] = z[i][3]
for i in range(len(x)):
	if i in d:
		print(d[i], end='')
	else:
		print(x[i], end='')


(n, m) = map(int, input().split())
s = list(input())
for i in range(0, m):
	(l, c, a, b) = input().split()
	(l, c) = map(int, [l, c])
	for j in range(l - 1, c):
		if s[j] == a:
			s[j] = b
print(''.join(s))


(n, m) = [int(x) for x in input().split()]
s = '$' + input()
for i in range(m):
	arr = input().split()
	for j in range(int(arr[0]), int(arr[1]) + 1):
		if s[j] == arr[2]:
			s = s[:j] + arr[3] + s[j + 1:]
print(s[1:])


def s():
	(n, m) = [int(x) for x in input().split(' ')]
	stri = input()
	for i in range(m):
		(l, r, c1, c2) = input().split(' ')
		substr = stri[int(l) - 1:int(r)].replace(c1, c2)
		stri = stri[:int(l) - 1] + substr + stri[int(r):]
	print(stri)
s()


(n, m) = map(int, input().split())
l = list(input())
for i in range(m):
	(a, b, c, d) = input().split()
	for j in range(int(a) - 1, int(b)):
		if l[j] == c:
			l[j] = d
for x in l:
	print(x, end='')


(n, m) = map(int, input().split())
s = input()
for _ in range(m):
	(l, r, c1, c2) = map(str, input().split())
	s1 = s[int(l) - 1:int(r)]
	s2 = s1.replace(c1, c2)
	s = s[0:int(l) - 1] + s2 + s[int(r):]
print(s)


(a, b) = map(int, input().split(' '))
c = input()
r = list(c)
for i in range(0, b):
	d = input().split(' ')
	for k in range(int(d[0]) - 1, int(d[1])):
		if r[k] == d[2]:
			r[k] = d[3]
for lo in range(0, a):
	print(r[lo], end='')


(n, m) = [int(x) for x in input().split()]
s = input()
for i in range(m):
	inputs = input().split()
	l = int(inputs[0]) - 1
	r = int(inputs[1]) - 1
	c1 = inputs[2]
	c2 = inputs[3]
	s = s[:l] + s[l:r + 1].replace(c1, c2) + s[r + 1:]
print(s)


(n, k) = map(int, input().split())
s = input()
p = []
for i in s:
	p += i
for i in range(k):
	m = input().split()
	for j in range(int(m[0]) - 1, int(m[1])):
		if p[j] == m[2]:
			p[j] = m[3]
s = ''
for i in p:
	s += i
print(s)


(n, m) = [int(i) for i in input().split()]
line = input()
for i in range(m):
	operation = input().split()
	for j in range(int(operation[0]) - 1, int(operation[1])):
		if line[j] == operation[2]:
			line = line[:j] + operation[3] + line[j + 1:]
print(line)


def Scarborough():
	(n, m) = list(map(int, input().split()))
	s = input()
	for i in range(m):
		(l, r, c1, c2) = input().split()
		l = int(l)
		r = int(r)
		for i in range(l - 1, r):
			if i == n - 1:
				if s[i] == c1:
					s = s[:i] + c2
			elif s[i] == c1:
				s = s[:i] + c2 + s[i + 1:]
	print(s)
Scarborough()


(n, m) = map(int, input().split())
r = input()
for i in range(m):
	(a, b, c, d) = input().split()
	r = r[:int(a) - 1] + r[int(a) - 1:int(b)].replace(c, d) + r[int(b):]
print(r)


(a, b) = map(int, input().split())
s = input()
sp = []
sp += s
res = ''
for i in range(b):
	(l, r, c1, c2) = map(str, input().split())
	for x in range(int(l), int(r) + 1):
		if sp[x - 1] == c1:
			sp[x - 1] = c2
for i in sp:
	res += i
print(res)


A = input().split()
n = int(A[0])
m = int(A[1])
S = list(input())
for i in range(0, m):
	B = input().split()
	l = int(B[0])
	r = int(B[1])
	old = B[2]
	new = B[3]
	for j in range(l - 1, r):
		if S[j] == old:
			S[j] = new
print(''.join(S))


(n, m) = map(int, input().split())
st = input()
strk = []
for i in range(n):
	strk.append(st[i])
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for j in range(l - 1, r):
		if strk[j] == c1:
			strk[j] = c2
st = ''
for i in range(n):
	st = st + strk[i]
print(st)


(n, o) = map(int, input().split())
str = list((i for i in input()))
for i in range(o):
	(l, r, c1, c2) = input().split()
	for j in range(int(l) - 1, int(r)):
		if str[j] == c1:
			str[j] = c2
print(*str, sep='')


(n, m) = [int(x) for x in input().split()]
s = input()
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	t = int(l)
	d = int(r)
	s = s[:t - 1] + s[t - 1:d].replace(c1, c2) + s[d:]
print(s)


def main():
	[_, m] = [int(x) for x in input().split()]
	origine = ' ' + input()
	intermediaire = None
	for i in range(m):
		tache_data = input().split()
		left = int(tache_data[0])
		right = int(tache_data[1])
		c1 = tache_data[2]
		c2 = tache_data[3]
		before = origine if intermediaire is None else intermediaire
		after = before[0:left] + before[left:right + 1].replace(c1, c2) + before[right + 1:]
		intermediaire = after
	result = intermediaire
	print(result[1:])
main()


def main():
	m = int(input().split()[1])
	s = input()
	for i in range(m):
		(l, r, c, d) = input().split()
		for j in range(int(l) - 1, int(r)):
			if s[j] == c:
				s = s[:j] + d + s[j + 1:]
	print(s)
main()


(n, m) = map(int, input().split())
t = list(input())
for i in range(m):
	q = input().split()
	(l, r, c, d) = (int(q[0]), int(q[1]), q[2], q[3])
	for i in range(l - 1, r):
		if t[i] == c:
			t[i] = d
print(*t, sep='')


(n, m) = map(int, input().split())
a = []
s = input()
a += s
for u in range(m):
	(l, r, c1, c2) = (i for i in input().split())
	for i in range(int(l) - 1, int(r)):
		if a[i] == c1:
			a[i] = c2
print(*a, sep='')


a = input()
n = a.split(' ')
m = int(n[1])
n = int(n[0])
s = input()
for i in range(m):
	a = input()
	a = a.split(' ')
	b = ''
	for i2 in s[int(a[0]) - 1:int(a[1])]:
		if i2 == a[2]:
			b += a[3]
		else:
			b += i2
	s = s[:int(a[0]) - 1] + b + s[int(a[1]):]
print(s)


info = input()
info = info.split()
info[0] = int(info[0])
info[1] = int(info[1])
line = input()
line = list(line)
for i in range(info[1]):
	change = input()
	change = change.split()
	change[0] = int(change[0])
	change[1] = int(change[1])
	for j in range(change[0] - 1, change[1]):
		if line[j] == change[2]:
			line[j] = change[3]
print(''.join(line))


(n, m) = map(int, input().split(' '))
s = input()
for _ in range(m):
	(l, r, c1, c2) = input().split(' ')
	(l, r) = (int(l), int(r))
	s = s[:l - 1] + c2.join(s[l - 1:r].split(c1)) + s[r:]
print(s)


def solve(string, ops):
	chars = list(string)
	for op in ops:
		(l, r, c1, c2) = op
		l = int(l)
		r = int(r)
		for i in range(l - 1, r):
			if chars[i] == c1:
				chars[i] = c2
	return ''.join(chars)

def main():
	(n, m) = list(map(int, input().split()))
	string = input()
	ops = []
	for _ in range(m):
		ops.append(input().split())
	print(solve(string, ops))
main()


data = input()
n = int(data.split(' ')[0])
m = int(data.split(' ')[1])
s = input()
for mm in range(m):
	data = input()
	data = data.split(' ')
	l = int(data[0])
	r = int(data[1])
	c1 = data[2]
	c2 = data[3]
	s = s[:l - 1] + s[l - 1:r].replace(c1, c2) + s[r:]
print(s)


(n, m) = [int(elem) for elem in input().split()]
string = input()
ops = []
for i in range(m):
	ops.append(input())
for operation in ops:
	operation = operation.split()
	left = int(operation[0]) - 1
	right = int(operation[1]) - 1
	subs = operation[2]
	final = operation[3]
	subs_string = string[left:right + 1]
	subs_string = subs_string.replace(subs, final)
	string = string[:left] + subs_string + string[right + 1:]
print(string)


(n, m) = map(int, input().split())
s = input()
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	l -= 1
	r -= 1
	new_s = ''
	for j in range(n):
		if l <= j <= r:
			if s[j] == c1:
				new_s += c2
			else:
				new_s += s[j]
		else:
			new_s += s[j]
	s = new_s
print(new_s)


(m, n) = map(int, input().split())
s = input()
for _ in range(n):
	x = input().split()
	s = s[:int(x[0]) - 1] + s[int(x[0]) - 1:int(x[1])].replace(x[2], x[3]) + s[int(x[1]):]
print(s)


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	(l, h, f, x) = map(str, input().split())
	for j in range(int(l) - 1, int(h), 1):
		if s[j] == f:
			s[j] = x
z = ''.join(s)
print(z)


(n, m) = map(int, input().split())
s = input()
for t in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	s_left = s[:l - 1]
	s_right = s[r:]
	s_mid = s[l - 1:r]
	s_mid = s_mid.replace(c1, c2)
	s = s_left + s_mid + s_right
print(s)


(x, y) = map(int, input().split())
A = list(map(str, input()))
for i in range(y):
	N = list(map(str, input().split()))
	(l, r) = (int(N[0]), int(N[1]))
	for j in range(l - 1, r, 1):
		if A[j] == N[2]:
			A[j] = N[3]
A = ''.join(A)
print(A)


(n, m) = map(int, input().split())
s = input()
arr = list(s)
for _ in range(m):
	(l, r, a, b) = map(str, input().split())
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if arr[i] == a:
			arr[i] = b
print(''.join(arr))


(n, m) = map(int, input().split())
s = list(input())
a = ''
for i in range(m):
	(l, j, c1, c2) = map(str, input().split())
	l = int(l)
	j = int(j)
	if l == j:
		if s[l - 1] == c1:
			s[l - 1] = c2
	else:
		for k in range(l - 1, j):
			if s[k] == c1:
				s[k] = c2
for i in range(n):
	a += s[i]
print(a)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	s = [c for c in S()]
	a = [LS() for _ in range(m)]
	for (b, c, d, e) in a:
		b = int(b) - 1
		c = int(c)
		for i in range(b, c):
			if s[i] == d:
				s[i] = e
	return ''.join(s)
print(main())


def read_input_from_file():
	with open('input.in', 'r') as file:
		lines = file.readlines()
	(n, m) = lines[0].split()
	string = lines[1][:-1]
	operations = lines[2:]
	return (n, m, string, operations)

def change_string(string, l, r, c1, c2):
	for i in range(int(l), int(r) + 1):
		if string[i - 1] == c1:
			string = string[:i - 1] + c2 + string[i:]
	return string

def main():
	(n, m) = [int(x) for x in input().split()]
	string = input()
	operations = []
	for i in range(0, m):
		operations.append(input())
	for operation in operations:
		string = change_string(string, *operation.split())
	print('{}'.format(string))
main()


aa = input().split()
a = int(aa[0])
b = int(aa[1])
l = list(input())
for i in range(0, b):
	work = input().split()
	for d in range(int(work[0]) - 1, int(work[1])):
		if l[d] == work[2]:
			l[d] = work[3]
print(''.join(l))


(n, k) = list(map(int, input().split()))
p = list(input())
for x in range(k):
	(d, f, g, h) = list(map(str, input().split()))
	for y in range(int(d) - 1, int(f)):
		if p[y] == g:
			p[y] = h
		else:
			pass
print(''.join(p))


(n, m) = map(int, input().split())
S = input()
S = list(S)
op = []
for i in range(m):
	(l, r, st, rep) = input().split()
	l = int(l) - 1
	r = int(r) - 1
	op.append([l, r, st, rep])
for (l, r, sy, rep) in op:
	for i in range(l, r + 1):
		if S[i] == sy:
			S[i] = rep
ans = ''
for i in S:
	ans += i
print(ans)


list_a = [int(x) for x in input().split()]
n = list_a[0]
m = list_a[1]
s = input()
list_m = []
for i in range(0, m):
	list_m = list_m + [[x for x in input().split()]]
for i in range(0, m):
	for j in range(0, 4):
		l = int(list_m[i][0])
		r = int(list_m[i][1])
		c0 = list_m[i][2]
		c1 = list_m[i][3]
		s = s[0:l - 1] + s[l - 1:r].replace(c0, c1) + s[r:len(s)]
print(s)


(n, m) = map(int, input().split())
s = input()
for j in range(m):
	f = input().split()
	l = int(f[0])
	r = int(f[1])
	x = f[2]
	y = f[3]
	for i in range(l - 1, r):
		if s[i] == x:
			s = s[:i] + y + s[i + 1:]
print(s)


(word_length, num_changes) = map(int, input().split())
word = list(input())
for _ in range(num_changes):
	(left, right, original, new) = input().split()
	left = int(left) - 1
	right = int(right) - 1
	for pos in range(left, right + 1):
		if word[pos] == original:
			word[pos] = new
print(''.join(word))


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	a = list(input().split())
	l = int(a[0])
	r = int(a[1])
	c1 = a[2]
	c2 = a[3]
	for j in range(l - 1, r):
		if s[j] == c1:
			s[j] = c2
print(''.join(s))


def FinalString(n, m, s, f):
	s = list(s)
	for i in range(m):
		l = int(f[i][0])
		u = int(f[i][1])
		for j in range(l - 1, u):
			if s[j] == f[i][2]:
				s[j] = f[i][3]
	res = ''
	for i in range(len(s)):
		res = res + s[i]
	return res
(n, m) = map(int, input().split())
s = input()
f = []
for i in range(m):
	f1 = [n for n in input().split()]
	f.append(f1)
print(FinalString(n, m, s, f))


import collections
Direction = collections.namedtuple('Direction', ['l', 'r', 'c1', 'c2'])
(n, m) = map(int, input().split())
slist = list(input())
directions = []
for _ in range(m):
	args = input().split()
	temp_d = Direction(int(args[0]), int(args[1]), args[2], args[3])
	directions.append(temp_d)
for d in directions:
	for i in range(d.l - 1, d.r):
		if slist[i] == d.c1:
			slist[i] = d.c2
print(''.join(slist))


(n, m) = list(map(int, input().split()))
s = list(input())

def get_operation():
	return input().split()

def do_operation(_operation):
	(l, r, c1, c2) = _operation
	l = int(l)
	r = int(r)
	for k in range(l - 1, r):
		if s[k] == c1:
			s[k] = c2
for k in range(m):
	operation = get_operation()
	do_operation(operation)
print(''.join(s))


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	(l, r, old, new) = input().split()
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if s[i] == old:
			s[i] = new
print(''.join(s))


(a, d) = ([int(i) for i in input().split()], input())
for i in range(a[1]):
	v = input().split()
	d = d[:int(v[0]) - 1] + d[int(v[0]) - 1:int(v[1])].replace(v[2], v[3]) + d[int(v[1]):]
print(d)


def scarborough_fair():
	(n, m) = map(int, input().split(sep=' '))
	st = list(input())
	for i in range(m):
		(l, r, c1, c2) = map(str, input().split(sep=' '))
		for j in range(int(l) - 1, int(r)):
			if st[j] == c1:
				st[j] = c2
	print(*st, sep='')
scarborough_fair()


(a, b) = list(map(int, input().split()))
c = list(input())
d = []
k = ''
for i in range(b):
	d.append(list(map(str, input().split())))
for i in range(len(d)):
	e = int(d[i][0])
	f = int(d[i][1])
	for j in range(e - 1, f):
		if c[j] == d[i][2]:
			c[j] = d[i][3]
for i in range(len(c)):
	k += c[i]
print(k)


(a, b) = map(int, input().split())
s = input()
for i in range(b):
	(x, y, z, t) = input().split()
	s = s[:int(x) - 1:1] + s[int(x) - 1:int(y)].replace(z, t) + s[int(y)::1]
print(s)


(a, b) = input().split()
(a, b) = (int(a), int(b))
c = input()
c = list(c)
for i in range(b):
	(d, e, f, g) = input().split()
	(d, e) = (int(d), int(e))
	for j in range(d - 1, e):
		if c[j] == f:
			del c[j]
			c.insert(j, g)
c = ''.join(c)
print(c)


(n, t) = [int(i) for i in input().split()]
string = [i for i in input()]
for i in range(t):
	(x, y, s1, s2) = [i for i in input().split()]
	x = int(x)
	y = int(y)
	for i in range(x - 1, y):
		if string[i] == s1:
			string[i] = s2
print(''.join(string))


(a, b) = map(int, input().split())
s = list(input())
for i in range(b):
	(l, r, c1, c2) = input().split()
	for j in range(int(l) - 1, int(r)):
		if s[j] == c1:
			s[j] = c2
print(''.join(s))


(n, m) = list(map(int, input().split()))
z = list(input())
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if z[i] == c1:
			z[i] = c2
print(''.join(z))


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l) - 1
	r = int(r) - 1
	one = s[:l]
	two = s[l:r + 1]
	three = s[r + 1:]
	for i in range(r - l + 1):
		if two[i] == c1:
			two[i] = c2
	s = one + two + three
print(''.join(s))


(n, m) = [int(x) for x in input().split()]
s = input()
k = list(s)
for _ in range(m):
	(x, y, a, b) = input().split()
	l = int(x)
	r = int(y)
	for i in range(l - 1, r):
		if k[i] == a:
			k[i] = b
d = ''
for j in range(len(k)):
	d += k[j]
print(d)


def yarmarka(lst, s):
	t = list(s)
	for elem in lst:
		for i in range(elem[0] - 1, elem[1]):
			if t[i] == elem[2]:
				t[i] = elem[3]
	return ''.join(t)
(n, m) = [int(j) for j in input().split()]
w = input()
a = list()
for x in range(m):
	(l, r, c1, c2) = [y for y in input().split()]
	a.append([int(l), int(r), c1, c2])
print(yarmarka(a, w))


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [[0, 1], [0, -1], [1, 0], [1, -1]]
NEIGHBOURS = [(i, j) for i in range(-1, 2) for j in range(-1, 2) if i != 0 or j != 0]
OrdUnicode_a = ord('a')
OrdUnicode_A = ord('A')
CAPS_ALPHABETS = {chr(i + OrdUnicode_A): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + OrdUnicode_a): i for i in range(26)}
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0) + 1
INFINITY = float('inf')
(n, m) = get_ints()
s = list(input())
for i in range(m):
	(a, b, c, d) = get_string()
	for j in range(int(a) - 1, int(b)):
		s[j] = d if s[j] == c else s[j]
print(''.join(s))


string = input().split(' ')
n = int(string[0])
m = int(string[1])
string = list(input())
for i in range(m):
	operation = input().split(' ')
	for j in range(int(operation[0]) - 1, int(operation[1])):
		if string[j] == operation[2]:
			string[j] = operation[3]
print(''.join(string))


n = list(map(int, input().split()))
a = str(input())
c = [i for i in a]
for i in range(n[1]):
	b = list(map(str, input().split()))
	for j in range(int(b[0]), int(b[1]) + 1):
		if c[j - 1] == b[2]:
			c[j - 1] = b[3]
for i in c:
	print(i, end='')


(n, m) = [int(x) for x in input().split()]
s = [c for c in input()]
oper = []
for _ in range(m):
	(a, b, c, d) = input().split()
	a = int(a)
	b = int(b)
	oper.append((a, b, c, d))
for op in oper:
	(l, r, c1, c2) = op
	for i in range(l - 1, r):
		if s[i] == c1:
			s[i] = c2
print(''.join(s))


import sys
import math
import bisect

def main():
	(n, m) = map(int, input().split())
	A = list(input())
	while m:
		m -= 1
		(l, r, c1, c2) = input().split()
		l = int(l) - 1
		r = int(r) - 1
		for i in range(l, r + 1):
			if A[i] == c1:
				A[i] = c2
	print(''.join(A))
main()


f = lambda : map(int, input().split())
(n, t) = f()
s = list(input())
while t:
	(l, r, c1, c2) = input().split()
	for i in range(int(l), int(r) + 1):
		if s[i - 1] == c1:
			s[i - 1] = c2
	t -= 1
print(''.join(s))


(n, m) = map(int, input().split())
string = list(input())
for i in range(m):
	n = input().split()
	for i in range(int(n[0]) - 1, int(n[1])):
		if string[i] == n[2]:
			string[i] = str(n[3])
for i in string:
	print(i, end='')


[n, m] = list(map(int, input().split()))
string = list(input())
obs = []
for i in range(m):
	obs.append(input().split())
for i in obs:
	(l, r, c1, c2) = (int(i[0]), int(i[1]), i[2], i[3])
	for j in range(r - l + 1):
		if string[j + l - 1] == c1:
			string[j + l - 1] = c2
print(''.join(string))


(n, m) = [int(i) for i in input().split()]
s = str(input())
for i in range(m):
	(a, b, c, d) = [str(i) for i in input().split()]
	a = int(a)
	b = int(b)
	e = s[a - 1:b]
	e = e.replace(c, d)
	s = s[0:a - 1] + e + s[b:]
print(s)


(n, m) = map(int, input().split())
a = list(input())
for i in range(m):
	l1 = list(input().split())
	(c1, c2, l, r) = (l1[2], l1[3], int(l1[0]), int(l1[1]))
	for j in range(l - 1, r):
		if a[j] == c1:
			a[j] = c2
print(*a, sep='')


(n, q) = map(int, input().split())
s = input()
for _ in range(q):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	s = [c2 if i + 1 >= l and i + 1 <= r and (s[i] == c1) else s[i] for i in range(len(s))]
print(''.join(s))


a = input().split(' ')
b = list(input())
c = int(a[1])
while c > 0:
	query = input().split(' ')
	for t in range(int(query[0]) - 1, int(query[1])):
		if b[t] == query[2]:
			b[t] = query[3]
	c -= 1
print(''.join(b))


(n, m) = list(map(int, input().split()))
a = list(input())
for i in range(m):
	(l, r, f, t) = input().split()
	for i in range(int(l) - 1, int(r)):
		if a[i] == f:
			a[i] = t
print(str().join(a))


(n, m) = map(int, input().split())
s = input()
for i in range(m):
	s1 = input().split()
	x = int(s1[0])
	y = int(s1[1])
	for j in range(x, y + 1):
		if s[j - 1] == s1[2]:
			s = s[:j - 1] + s1[3] + s[j:]
print(s)


(n, m) = map(int, input().split())
s = list(input())
q = ''
for i in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for j in range(l - 1, r):
		if s[j] == c1:
			s[j] = c2
for k in s:
	q += k
print(q)


R = lambda : map(int, input().split())
(n, m) = R()
s = str(input())
for i in range(m):
	(l, r, a, b) = input().split()
	(l, r) = (int(l), int(r))
	for j in range(l, r + 1):
		if s[j - 1] == a:
			if j > 1 and j < n:
				s = s[:j - 1] + b + s[j:]
			if j == 1:
				s = b + s[j:]
			if j == n:
				s = s[:j - 1] + b
print(s)


(n, m) = (int(i) for i in input().split())
st = input()
for i in range(m):
	dts = input().split()
	st = st[:int(dts[0]) - 1] + st[int(dts[0]) - 1:int(dts[1])].replace(dts[2], dts[3]) + st[int(dts[1]):]
print(st)


list0 = input().split()
(n, m) = list0
n = int(n)
m = int(m)
s = list(input())
i = 1
while i <= m:
	list1 = input().split()
	(l, r, c1, c2) = list1
	l = int(l)
	r = int(r)
	j = l - 1
	while j < r:
		if s[j] == c1:
			s[j] = c2
		j = j + 1
	i = i + 1
st = ''.join((str(e) for e in s))
print(st)


for a in range(int(input().split(' ')[1])):
	if a == 0:
		s = input()
	m = input().split(' ')
	s = s[:int(m[0]) - 1] + s[int(m[0]) - 1:int(m[1])].replace(m[2], m[3]) + s[int(m[1]):]
print(s)


(n, m) = map(int, input().split())
string = input()
for _ in range(m):
	lst = input().split()
	x = int(lst[0]) - 1
	y = int(lst[1]) - 1
	if x > 0 and y < n - 1:
		string = string[:x] + string[x:y + 1].replace(lst[2], lst[3]) + string[y + 1:]
	elif y < n - 1:
		string = string[x:y + 1].replace(lst[2], lst[3]) + string[y + 1:]
	elif x > 0:
		string = string[:x] + string[x:y + 1].replace(lst[2], lst[3])
	else:
		string = string[x:y + 1].replace(lst[2], lst[3])
print(string)


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	inp_array = input().split()
	l = int(inp_array[0])
	r = int(inp_array[1])
	c1 = inp_array[2]
	c2 = inp_array[3]
	for j in range(l - 1, r):
		if s[j] == c1:
			s[j] = c2
answer = ''
for el in s:
	answer += el
print(answer)


nm = input().split()
a = input()
for i in range(int(nm[1])):
	b = input().split()
	c = int(b[0]) - 1
	d = int(b[1])
	a = a[:c] + a[c:d].replace(b[2], b[3]) + a[d:]
print(a)


(n, m) = map(int, input().split())
s = input()
for i in range(m):
	(l, r, x, y) = map(str, input().split())
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if s[i] == x:
			s = s[:i] + y + s[i + 1:]
print(s)


(n, m) = [int(tmp) for tmp in input().split()]
s = input()
a = []
for i in range(n):
	a.append(s[i])
for i in range(m):
	(aa, b, c, d) = [str(tmp) for tmp in input().split()]
	for j in range(int(aa) - 1, int(b)):
		if a[j] == c:
			a[j] = d
print(''.join(map(str, a)))


inp = input().split()
(n, m) = (int(inp[0]), int(inp[1]))
mystr = list(input())
for i in range(m):
	(a, b, c, d) = input().split()
	a = int(a) - 1
	b = int(b) - 1
	if b > len(mystr):
		b = len(mystr) - 2
	if a < 0:
		a = 0
	for j in range(a, b + 1):
		if mystr[j] == c:
			mystr[j] = d
print(''.join(mystr))


(a, b) = map(int, input().split())
s = input()
m = ''
for i in range(b):
	(k, l, c1, c2) = map(str, input().split())
	for j in range(a):
		if j + 1 >= int(k) and j + 1 <= int(l) and (s[j] == c1):
			m += c2
		else:
			m += s[j]
	s = m
	m = ''
print(s)


(n, k) = input().split()
(n, k) = (int(n), int(k))
s = input()
s = [x for x in s]
for i in range(k):
	(w, x, y, z) = input().split()
	(w, x) = (int(w), int(x))
	for j in range(w - 1, x):
		if s[j] == y:
			s[j] = z
print(''.join(s))


(n, m) = input().split()
(n, m) = (int(n), int(m))
string = input()
iterator = []
for i in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l) - 1, int(r) - 1)
	iterator.append((l, r, c1, c2))
for step in iterator:
	(l, r, c1, c2) = (step[0], step[1], step[2], step[3])
	for k in range(l, r + 1):
		if string[k] == c1:
			string = string[0:k] + c2 + string[k + 1:len(string)]
print(string)


(q, w) = map(int, input().split())
s = ['0'] + [i for i in input()]

def f(b, n, m):
	for i in range(0, len(b)):
		if b[i] == n:
			b[i] = m
	return b
for i in range(0, w):
	(z, x, c, v) = input().split()
	(z, x) = (int(z), int(x))
	s = s[:z] + f(s[z:x + 1], c, v) + s[x + 1:]
print(''.join(s[1:]))


(n, m) = map(int, input().split())
a = list(input())
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for j in range(l - 1, r):
		if a[j] == c1:
			a[j] = c2
for c in a:
	print(c, end='')


(n, k) = map(int, input().split())
s = input()
l = list(s)
for o in range(k):
	x = input().split()
	a = int(x[0]) - 1
	b = int(x[1]) - 1
	if a == b and l[a] == x[2]:
		l[a] = x[3]
	else:
		for i in range(a, b + 1):
			if l[i] == x[2]:
				l[i] = x[3]
s = ''
for i in range(n):
	s = s + l[i]
print(s)


(n, m) = map(int, input().split())
string = list(input())
for i in range(m):
	(a, b, x, y) = input().split()
	a = int(a)
	b = int(b)
	for j in range(a - 1, b):
		if string[j] == x:
			string[j] = y
print(''.join(string))


import string
ilkSatir = input()
ikinciSatir = input()
ilkSatirElemanlari = ilkSatir.split(' ')
text = str(ikinciSatir)
satirSayisi = int(ilkSatirElemanlari[1])
for i in range(satirSayisi):
	islem = input().split()
	kesitUzunlugu = int(islem[1]) - int(islem[0])
	for k in range(kesitUzunlugu + 1):
		a = int(islem[0]) - 1 + k
		if text[a] == islem[2]:
			text = text[0:a] + islem[3] + text[a + 1:len(text)]
print(text)


n = int(input().split()[-1])
s = input()
for i in range(n):
	(l, r, c1, c2) = input().split()
	l = int(l) - 1
	r = int(r)
	b = s[l:r].replace(c1, c2)
	s = s[:l] + b + s[r:]
print(s)


def repl(word, l, r, c1, c2):
	a = word[:l]
	b = word[l:r]
	c = word[r:]
	return a + b.replace(c1, c2) + c
inp_1 = [int(i) for i in input().split()]
n = inp_1[0]
m = inp_1[1]
word = input()
for i in range(m):
	lst = input().split()
	word = repl(word, int(lst[0]) - 1, int(lst[1]), lst[2], lst[3])
print(word)


a = list(map(int, input().split()))
n = a[0]
m = a[1]
s = input()
q = []
for i in range(n):
	q.append(s[i])
for x in range(m):
	d = list(input().split())
	l = int(d[0])
	r = int(d[1])
	c1 = d[2]
	c2 = d[3]
	for c in range(l, r + 1):
		if q[c - 1] == c1:
			q[c - 1] = c2
for p in range(n):
	print(q[p], end='')


(n, m) = map(int, input().split())
si = input()
s = []
for ns in si:
	s.append(ns)
for _ in range(m):
	ss = list(input().split())
	if ss[0] == ss[1]:
		if s[int(ss[0]) - 1] == ss[2]:
			s[int(ss[0]) - 1] = ss[3]
	else:
		for i in range(int(ss[0]) - 1, int(ss[1])):
			if s[i] == ss[2]:
				s[i] = ss[3]
print(''.join(s))


(size, no_of_operations) = map(int, input().split(' '))
word = input()

def op(word, l, r, c1, c2):
	return ''.join([c2 if i in range(l - 1, r) and word[i] == c1 else word[i] for i in range(len(word))])
for i in range(no_of_operations):
	(l, r, c1, c2) = input().split(' ')
	word = op(word, int(l), int(r), c1, c2)
print(word)


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	x = input()
	(r, c) = map(int, x[:-4].split())
	for j in range(r - 1, c):
		if s[j] == x[-3]:
			s[j] = x[-1]
print(''.join(s))


(nos, noq) = [int(x) for x in input().split()]
s = list(input())
for _ in range(noq):
	(l, r, c1, c2) = [x for x in input().split()]
	(l, r) = (int(l), int(r))
	while l <= r:
		if s[l - 1] == c1:
			s[l - 1] = c2
		l += 1
print(''.join(s))


(n, m) = map(int, input().split())
s = input()
l = []
for i in range(m):
	l.append(input().split())
for i in l:
	i[0] = str(int(i[0]) - 1)
	i[1] = str(int(i[1]) - 1)
for i in range(len(l)):
	s = s[:int(l[i][0])] + str.replace(s[int(l[i][0]):int(l[i][1]) + 1], l[i][2], l[i][3]) + s[int(l[i][1]) + 1:]
print(s)


(n, cases) = map(int, input().split())
s = list(input())
while cases:
	cases -= 1
	(l, r, c1, c2) = input().split()
	l = int(l) - 1
	r = int(r)
	for i in range(l, r):
		if s[i] == c1:
			s[i] = c2
print(''.join(s))


(n, m) = input().split()
n = int(n)
m = int(m)
s = input()
str = []
for i in range(len(s)):
	str.append(s[i])
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for i in range(r - l + 1):
		if str[l - 1] == c1:
			str[l - 1] = c2
		l = l + 1
print(''.join(str))


(n, m) = map(int, input().split())
s = input()
a = list(s)
e = ''
for i in range(m):
	lis = list(input().split())
	b = int(lis[0])
	c = int(lis[1])
	for j in range(b - 1, c):
		if a[j] == lis[2]:
			a[j] = lis[3]
print(e.join(a))


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)
(length, amount) = map(int, f_input().split())
string = list(f_input().replace('\n', ''))
for _ in range(amount):
	data = [_ for _ in f_input().split()]
	(l, r) = (int(data[0]), int(data[1]))
	(initial, change) = (data[2], data[3])
	for i in range(l - 1, r):
		if string[i] == initial:
			string[i] = change
f_print(''.join(string))


(n, m) = map(int, input().split())
s = input()
for i in range(m):
	(x, y, c, p) = input().split()
	x = int(x) - 1
	y = int(y)
	s = s[0:x] + s[x:y].replace(c, p) + s[y:]
print(s)


(n, m) = [int(item) for item in input().strip().split(' ')]
s = list(input().strip())
for i in range(m):
	(start, finish, before, after) = input().strip().split()
	(start, finish) = (int(start) - 1, int(finish) - 1)
	for num in range(start, finish + 1):
		if s[num] == before:
			s[num] = after
print(''.join(s))


(n, m) = map(int, input().split())
st = input()
for i in range(m):
	(l, r, c1, c2) = map(str, input().split())
	l = int(l)
	r = int(r)
	x = st[l - 1:r]
	x = x.replace(c1, c2)
	y = st[r:]
	st = st[0:l - 1] + x + y
print(st)


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	a = list(input().split())
	l = int(a[0])
	r = int(a[1])
	c1 = a[2]
	c2 = a[3]
	for i in range(l - 1, r):
		if s[i] == c1:
			s[i] = c2
print(''.join(s))


(length, n_operations) = map(int, input().split())
string = list(input())
for i in range(n_operations):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for j in range(l - 1, r):
		if string[j] == c1:
			string[j] = c2
print(''.join(string))


(n, m) = list(map(int, input().split()))
string = str(input())
for i in range(m):
	(l1, l2, c1, c2) = input().split()
	l1 = int(l1)
	l2 = int(l2)
	c1 = str(c1)
	c2 = str(c2)
	string = string[0:l1 - 1] + string[l1 - 1:l2].replace(c1, c2) + string[l2:n + 1]
print(string)


import bisect

def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
[n, m] = list(map(int, input().split()))
s = list(input())
for _ in range(m):
	[l, r, c1, c2] = list(input().split())
	l = int(l)
	r = int(r)
	l -= 1
	r -= 1
	for i in range(l, r + 1):
		if s[i] == c1:
			s[i] = c2
print(''.join(map(str, s)))


(n, m) = input().split()
n = int(n)
m = int(m)
string = input()
for i in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for k in range(l - 1, r, +1):
		if string[k] == c1:
			string = string[:k] + c2 + string[k + 1:]
print(string)


class CodeforcesTask897ASolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.string = []
		self.operations = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		self.string = list(input())
		for x in range(self.n_m[1]):
			self.operations.append(input().split(' '))

	def process_task(self):
		for op in self.operations:
			for x in range(int(op[0]) - 1, int(op[1])):
				if self.string[x] == op[2]:
					self.string[x] = op[3]
		self.result = ''.join(self.string)

	def get_result(self):
		return self.result
Solution = CodeforcesTask897ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(An, q) = map(int, input().split())
s = list(input())
for _ in range(q):
	(ls, rs, c1, c2) = input().split()
	(l, r) = map(int, (ls, rs))
	for i in range(l - 1, r):
		if s[i] == c1:
			s[i] = c2
print(*s, sep='')


from math import ceil

def main():
	(n, m) = [int(v) for v in input().split()]
	inp = input()
	for i in range(m):
		(s, e, source, target) = [v for v in input().split()]
		start = int(s) - 1
		end = int(e) - 1
		inp = inp[0:start] + inp[start:end + 1].replace(source, target) + inp[end + 1:]
	print(inp)
main()


line1 = list(input().split())
line2 = list(input())
line3 = [None] * int(line1[1])
for i in range(int(line1[1])):
	line3[i] = list(input().split())
	for j in range(int(line3[i][0]) - 1, int(line3[i][1])):
		if line2[j] == line3[i][2]:
			line2[j] = line3[i][3]
for i in line2:
	print(i, end='')


(a, b) = map(int, input().split())
str_a = input()
l_a = []
for k in str_a:
	l_a.append(k)
for i in range(b):
	(m, n, o, p) = input().split()
	l_b = []
	for s in range(int(m) - 1, int(n)):
		if l_a[s] == o:
			l_a[s] = p
for j in l_a:
	print(j, end='')


(a, b) = map(int, input().split())
s = [x for x in input()]
for i in range(b):
	c = input().split()
	(c[0], c[1]) = (int(c[0]), int(c[1]))
	for x in range(c[0] - 1, c[1]):
		if s[x] == c[2]:
			s[x] = c[3]
print(''.join(s))


try:
	(n, m) = map(int, input().split())
	s = input()
	for each in range(0, m, 1):
		(l, r, c1, c2) = map(str, input().split())
		l = int(l)
		r = int(r)
		start = s[0:l - 1]
		mid = s[l - 1:r]
		last = s[r:n + 1]
		for each_l in mid:
			if each_l == c1:
				start = start + c2
			else:
				start = start + each_l
		s = start + last
	print(s)
except:
	pass


(a, b) = map(int, input().split())
x = list(input())
for i in range(b):
	c = list(map(str, input().split()))
	p = int(c[0]) - 1
	q = int(c[1]) - 1
	for j in range(p, q + 1):
		if x[j] == c[2]:
			x[j] = c[3]
print(*x, sep='')


import string
import re

def fair():
	n_m = input()
	(n, m) = n_m.split()
	str = input()
	myList = [None] * int(m)
	for i in range(0, int(m)):
		myList[i] = input()
	for i in range(0, int(m)):
		(l, r, c1, c2) = myList[i].split()
		if int(l) == int(r):
			str = str[:int(l) - 1] + re.sub(c1, c2, str[int(l) - 1]) + str[int(r):]
		else:
			str = str[:int(l) - 1] + re.sub(c1, c2, str[int(l) - 1:int(r)]) + str[int(r):]
	print(str)
fair()


x = input().split()
(n, m) = (int(x[0]), int(x[1]))
s = [i for i in input()]
for t in range(m):
	x = input().split()
	(l, r, c1, c2) = (int(x[0]) - 1, int(x[1]) - 1, x[2], x[3])
	for i in range(l, r + 1):
		if s[i] == c1:
			s[i] = c2
print(''.join(s))


(n, m) = [int(x) for x in input().split()]
x = input()
y = []
for c in x:
	y.append(c)
for _ in range(m):
	(l, r, a, b) = [x for x in input().split()]
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if y[i] == a:
			y[i] = b
print(''.join(y))


import sys
line = sys.stdin.readline().strip()
(n, m) = map(int, line.split())
s = sys.stdin.readline().strip()
s_list = list(s)
for i in range(m):
	line = sys.stdin.readline().strip()
	(l, r, c1, c2) = line.split()
	(l, r) = (int(l) - 1, int(r))
	for j in range(l, r):
		if s_list[j] == c1:
			s_list[j] = c2
print(''.join(s_list))


l1 = [int(i) for i in input().split()]
(n, m, x, res) = (l1[0], l1[1], list(input()), [])
for i in range(m):
	res.append(input().split())
for i in res:
	for p in range(int(i[0]) - 1, int(i[1])):
		if x[p] == i[2]:
			x[p] = i[3]
print(''.join(x))


n = input().split()
s = input()
for i in range(int(n[1])):
	li_st = input().split()
	f = li_st[0]
	l = li_st[1]
	b = li_st[2]
	c = li_st[3]
	s = s[:int(f) - 1] + s[int(f) - 1:int(l)].replace(b, c) + s[int(l):]
print(s)


(n, m) = map(int, input().strip().split())
s = input().strip()
for _ in range(m):
	(l, r, c1, c2) = input().strip().split()
	l = int(l) - 1
	r = int(r) - 1
	t = s[l:r + 1]
	t = t.replace(c1, c2)
	s = s[:l] + t + s[r + 1:]
print(s)


(string_length, test_case) = map(int, input().split())
st = list(input())
for x in range(test_case):
	(start, end, frm, to) = map(str, input().split())
	for y in range(int(start) - 1, int(end)):
		if st[y] == frm:
			st[y] = to
print(''.join(st))


(n, m) = list(map(int, input().split()))
st = input()
for i in range(m):
	(a, b, c, d) = list(input().split())
	in_ = st[int(a) - 1:int(b)]
	in_ = in_.replace(c, d)
	st = st[:int(a) - 1] + in_ + st[int(b):]
print(st)


(x, y) = [int(x) for x in input().split()]
a = input()
k = list(a)
for _ in range(y):
	(p, q, r, s) = [str(x) for x in input().split()]
	e = int(p)
	f = int(q)
	for i in range(e - 1, f):
		if k[i] == r:
			k[i] = s
print(''.join(k))


def main():
	(n, m) = map(int, input().split())
	l = list(input())
	for _ in range(m):
		(lo, hi, a, b) = input().split()
		for i in range(int(lo) - 1, int(hi)):
			if l[i] == a:
				l[i] = b
	print(''.join(l))
main()


(n, m) = map(int, input().split())
s = input()
w = list()
for i in range(m):
	(l, r, a, b) = map(str, input().split())
	l = int(l)
	r = int(r)
	for z in range(n):
		w.append(s[z])
	for j in range(l - 1, r, 1):
		if s[j] == a:
			w[j] = b
	s = ''
	for z in range(n):
		s += w[z]
print(s)


(n, m) = [int(i) for i in input().split()]
lyric = list(input())
for i in range(m):
	(l1, r1, c1, c2) = input().split()
	(l, r) = (int(l1), int(r1))
	for j in range(l - 1, r):
		if lyric[j] == c1:
			lyric.pop(j)
			lyric.insert(j, c2)
print(''.join(lyric))


(n, m) = list(map(int, input().strip().split()))
s = list(input().strip())
for _ in range(m):
	(l, r, c1, c2) = list(input().strip().split())
	for k in range(int(l) - 1, int(r)):
		if s[k] == c1:
			s[k] = c2
print(''.join(s))


input1 = input()
n = int(input1.split()[0])
m = int(input1.split()[1])
list1 = list(input())
for i in range(m):
	temp = input()
	l = int(temp.split()[0])
	r = int(temp.split()[1])
	c1 = temp.split()[2]
	c2 = temp.split()[3]
	for j in range(l - 1, r):
		if list1[j] == c1:
			list1[j] = c2
print(''.join(list1))


(n, m) = [int(i) for i in input().split(' ')]
txt = input()
for i in range(m):
	command = input()
	spi = command.split(' ')
	(l, r, c1, c2) = (int(spi[0]) - 1, int(spi[1]) - 1, spi[2], spi[3])
	if r + 1 < n:
		txt = txt[0:l] + txt[l:r + 1].replace(c1, c2) + txt[r + 1:]
	else:
		txt = txt[0:l] + txt[l:].replace(c1, c2)
print(txt)


(length, number_of_operations) = map(int, input().split())
string = input()
for j in range(0, number_of_operations):
	(l, r, c1, c2) = input().split()
	l = int(l) - 1
	r = int(r) - 1
	if l == 0 and r == len(string) - 1:
		string = string[l:r + 1].replace(c1, c2)
	elif l == 0 and r != len(string) - 1:
		string = string[l:r + 1].replace(c1, c2) + string[r + 1:len(string)]
	elif l != 0 and r == len(string) - 1:
		string = string[0:l] + string[l:r + 1].replace(c1, c2)
	else:
		string = string[0:l] + string[l:r + 1].replace(c1, c2) + string[r + 1:len(string)]
print(string)


line = [int(i) for i in input().split()]
(n, m) = (line[0], line[1])
s = input()
ss = list(s)
for _ in range(m):
	line = input().split()
	(l, r, c1, c2) = (int(line[0]), int(line[1]), line[2], line[3])
	for i in range(l - 1, r):
		if ss[i] == c1:
			ss[i] = c2
print(''.join(ss))


lista = []
a = input().split(' ')
b = input()
for i in range(int(a[-1])):
	lista.append(input().split(' '))
for j in range(len(lista)):
	for k in range(len(b)):
		if lista[j][2] == b[k] and k + 1 >= int(lista[j][0]) and (k + 1 <= int(lista[j][1])):
			b = b[:k] + b[k].replace(lista[j][-2], lista[j][-1]) + b[k + 1:]
print(b)


def main():
	(N, M) = map(int, input().split())
	S = input()
	X = tuple((tuple(input().split()) for _ in [0] * M))
	str_ = list(S)
	for (l, r, c1, c2) in X:
		l = int(l) - 1
		r = int(r)
		for (i, s) in enumerate(str_[l:r]):
			if c1 in s:
				str_[l + i] = c2
	print(''.join(str_))
main()


(n, m) = map(int, input().split())
s = input()
lst = []
for i in range(n):
	lst.append(s[i].strip())
for _ in range(m):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l) - 1, int(r))
	for i in range(l, r):
		if lst[i] == c1:
			lst[i] = c2
print(''.join(lst))


(n, m) = [int(x) for x in input().split()]
s = input()
for i in range(m):
	(l, r, c1, c2) = [x for x in input().split()]
	s1 = s[:int(l) - 1]
	for (i, ch) in enumerate(s[int(l) - 1:int(r)]):
		if ch == c1:
			s1 += c2
		else:
			s1 += ch
	s1 += s[int(r):]
	s = s1
print(s)


(n, t) = map(int, input().split())
str1 = input()
str1 = list(str1)
for _ in range(t):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if str1[i] == c1:
			str1[i] = c2
print(''.join(str1))


(n, m) = [int(x) for x in input().split()]
s = list(input())
for i in range(m):
	(l, r, c1, c2) = [str(x) for x in input().split()]
	l = int(l)
	r = int(r)
	for j in range(l, r + 1):
		if s[j - 1] == c1:
			s[j - 1] = c2
print(*s, sep='')


(n, m) = map(int, input().split())
arr = list(input().strip())
for _ in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	for i in range(l - 1, r):
		if arr[i] == c1:
			arr[i] = c2
print(''.join(arr))


import itertools
import re
import math
import getpass
import sys
import string
debug = getpass.getuser() == 'frohe'
files = True
if debug and files:
	sys.stdin = open('test.in')
else:
	pass

def ria():
	return [int(i) for i in input().split()]
(n, m) = ria()
st = input()
for i in range(m):
	(l, r, a, b) = input().split()
	l = int(l)
	r = int(r)
	l -= 1
	st = st[:l] + st[l:r].replace(a, b) + st[r:]
print(st)


import copy
x = input().split(' ')
n = int(x[0])
m = int(x[1])
line = list(input())
new_line = copy.copy(line)
for _ in range(m):
	x = input().split(' ')
	l = int(x[0])
	r = int(x[1])
	for i in range(l - 1, r):
		if line[i] == x[2]:
			line[i] = x[3]
print(''.join(line))


(_, m) = [int(x) for x in input().split()]
s = list(input())
for ii in range(m):
	args = input().split()
	(l, r) = (int(args[0]), int(args[1]))
	(c1, c2) = (args[2], args[3])
	for j in range(l - 1, r):
		if s[j] == c1:
			s[j] = c2
print(''.join(s))


(n, m) = [int(i) for i in input().split()]
s = input()
a = []
for i in s:
	a.append(i)
for i in range(m):
	(x, y, c, b) = input().split()
	x = int(x)
	y = int(y)
	for j in range(x - 1, y):
		if a[j] == c:
			a[j] = b
for i in a:
	print(i, end='')


a = input().split()
st = input()
p = []
for i in range(len(st)):
	p.append(st[i])
for i in range(int(a[1])):
	b = input().split()
	for q in range(int(b[0]) - 1, int(b[1])):
		if p[q] == b[2]:
			p[q] = b[3]
for i in range(len(st)):
	print(p[i], end='')


import sys
(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	(a, b, c1, c2) = input().split()
	(a, b) = (int(a), int(b))
	for i in range(a, b + 1):
		if s[i - 1] == c1:
			s[i - 1] = c2
s = ''.join(s)
print(s)


class scarBoroughFair:

	def __init__(self, n, m):
		self.n = n
		self.m = m
		self.directions(self.n, self.m)

	def directions(self, n, m):
		str1 = input()
		str2 = ''
		list1 = list(str1)
		if len(str1) == n:
			pass
		else:
			exit()
		for x in range(0, m):
			(l, r, c1, c2) = map(str, input().split())
			for x in range(int(l) - 1, int(r)):
				if c1 == str1[x]:
					list1[x] = c2
					str1 = ''.join(list1)
		print(str1)
(n, m) = map(int, input().split())
scarBoroughFairObj = scarBoroughFair(n, m)


(n, m) = list(map(int, input().split()))
s = input()
for i in range(m):
	(l, r, c1, c2) = list(input().split())
	z = s[int(l) - 1:int(r)]
	y = z.replace(c1, c2)
	st = s[:int(l) - 1] + y + s[int(r):]
	s = st
print(s)


def answer():
	a = [int(x) for x in input().split()]
	p = a[0]
	n = a[1]
	targ = list(input())
	while n:
		t = input().split()
		l = int(t[0])
		r = int(t[1])
		c1 = t[2]
		c2 = t[3]
		i = l - 1
		while i < r:
			if targ[i] == c1:
				targ[i] = c2
			i += 1
		n -= 1
	c_out = ''
	for x in targ:
		c_out += x
	print(c_out)
answer()


(n, m) = list(map(int, input().strip().split()))
a = input()
for j in range(m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	b = a[l - 1:r]
	if c1 in b:
		b = b.replace(c1, c2)
		a = a[:l - 1] + b + a[r:]
	else:
		a = a
		pass
print(a)


[n, m] = list(map(int, input().split()))
string = input()
change_order = [dict() for x in range(n)]
new_string = list(string)
for i in range(0, m):
	[l1, h1, c1, c2] = list(input().split())
	l1 = int(l1)
	h1 = int(h1)
	if l1 == h1:
		if new_string[l1 - 1] == c1:
			new_string[l1 - 1] = c2
	else:
		for j in range(l1, h1 + 1):
			if new_string[j - 1] == c1:
				new_string[j - 1] = c2
new = ''.join(new_string)
print(new)


(n, m) = map(int, input().split())
line = input()
i = 1
while i <= m:
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	while l <= r:
		if line[l - 1] == c1:
			if l == n:
				line = line[:l - 1] + c2
			else:
				line = line[:l - 1] + c2 + line[l:]
		l += 1
	i += 1
print(line)


nm = list(map(int, input().split()))
s = list(map(str, input()))
for i in range(nm[1]):
	lrc = list(map(str, input().split()))
	for j in range(int(lrc[0]) - 1, int(lrc[1])):
		if s[j] == lrc[2]:
			s[j] = lrc[3]
print(*s, sep='')


(n, m) = input().split(' ')
m = int(m)
word = input()
lst = list(word)
for i in range(m):
	(a, b, c, d) = input().split(' ')
	a = int(a)
	b = int(b)
	for j in range(a - 1, b):
		if lst[j] == c:
			lst[j] = d
print(''.join(lst))


length = input().split(' ')
operations = int(length[1])
length = int(length[0])
string = input()
opers = []
for x in range(operations):
	opers.append(input().split(' '))
for oper in opers:
	for item in range(len(string)):
		if item + 1 >= int(oper[0]) and item + 1 <= int(oper[1]):
			if string[item] == oper[2]:
				string = string[:item] + oper[3] + string[item + 1:]
print(string)


l = list(input().split())
n = int(l[0])
m = int(l[1])
s = input()
s = [char for char in s]
for i in range(m):
	a = list(input().split())
	l = int(a[0])
	r = int(a[1])
	c1 = a[2]
	c2 = a[3]
	for j in range(l - 1, r):
		if s[j] == c1:
			s[j] = c2
		else:
			continue
print(''.join(s))


n_m = input().split(' ')
n = int(n_m[0])
m = int(n_m[1])
string = input()
for i in range(m):
	new = ''
	l_r_c = input().split(' ')
	lower = int(l_r_c[0]) - 1
	upper = int(l_r_c[1]) - 1
	word = l_r_c[2]
	replace = l_r_c[3]
	new_string = string[lower:upper + 1]
	new_string = list(new_string)
	count = 0
	for each in new_string:
		if each == word:
			new_string[count] = replace
		else:
			pass
		count += 1
	for i in new_string:
		new += i
	string = string[0:lower] + new + string[upper + 1:n]
print(string)


from sys import stdin
(n, m) = [int(i) for i in stdin.readline().split(' ')]
s = stdin.readline()[:-1]
trim = lambda s: s[:-1] if s[-1] == '\n' else s
for i in range(0, m):
	data = trim(stdin.readline().split(' '))
	l = int(data[0])
	r = int(data[1])
	c1 = data[2]
	c2 = trim(data[3])
	for i in range(l - 1, r):
		if s[i] == c1:
			s = s[:i] + c2 + s[i + 1:]
print(s)


(n, m) = map(int, input().split())
s = list(input())
for i in range(m):
	(l, r, a, b) = input().split()
	(l, r) = (int(l) - 1, int(r))
	for j in range(l, r):
		s[j] = b if s[j] == a else s[j]
print(''.join(s))


def main():
	(n, m) = input().strip().split()
	n = int(n)
	m = int(m)
	s = input()
	for i in range(m):
		(l, r, c1, c2) = input().strip().split()
		l = int(l) - 1
		r = int(r)
		t = s[l:r]
		for (i, x) in enumerate(t):
			if x == c1:
				t = t[:i] + c2 + t[i + 1:]
		s = s[:l] + t + s[r:]
	print(s)
main()


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(N, M) = map(int, input().split())
S = list(input())
for i in range(M):
	(l, r, c1, c2) = input().split()
	(l, r) = (int(l), int(r))
	for j in range(l - 1, r):
		if S[j] == c1:
			S[j] = c2
print(''.join(S))


(a, b) = list(map(int, input().split()))
s = list(map(str, input()))
for i in range(b):
	r = list(map(str, input().split()))
	for j in range(int(r[0]) - 1, int(r[1])):
		g = str(r[3])
		if s[j] == r[2]:
			s[j] = g
print(*s, sep='')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(n, k) = LI()
	s = list(S())
	for _ in range(k):
		(a, b, c, d) = LS()
		a = int(a)
		b = int(b)
		for i in range(a - 1, b):
			if s[i] == c:
				s[i] = d
	return ''.join([str(x) for x in s])
print(main())


(a, b) = map(int, input().split())
s = input()
for i in range(b):
	l = input().split()
	(in1, in2, le1, le2) = (int(l[0]), int(l[1]), l[2], l[3])
	s = s[:in1 - 1] + s[in1 - 1:in2].replace(le1, le2) + s[in2:]
print(s)


a = list(map(int, input().split()))
n = a[0]
m = a[1]
s = input()
for t in range(0, m):
	(l, r, c1, c2) = input().split()
	l = int(l)
	r = int(r)
	s = s[0:l - 1] + s[l - 1:r].replace(c1, c2) + s[r:]
print(s)