#include <stdio.h>
借鉴了一种认为比较好的代码
int main() {
    int n, m, l, r;
    char s[1000] = {0}, c1, c2;
    scanf("%d %d\n%s", &n, &m, &s);
    for (int i = 0; i < m; i++) { 
        scanf("%d %d %c %c\n", &l, &r, &c1, &c2);
        for (int j = l; j <= r; j++) {  
            if (s[j - 1] == c1) s[j - 1] = c2;  
        }
    }
    printf("%s", s);  
    return 0;
}