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