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

for _ in range(m):
    a, b, c, d = input().split()
    a, b = int(a), int(b)  

    s_list = list(s)

    for i in range(a-1, b):
        if s_list[i] == c:
            s_list[i] = d

    s = "".join(s_list)

print(s)