import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); in.nextLine(); String s = in.nextLine(); while(m-- > 0) { String[] line = in.nextLine().split(" "); int l = Integer.parseInt(line[0]); int r = Integer.parseInt(line[1]); char c1 = line[2].charAt(0); char c2 = line[3].charAt(0); s = replace(s, l, r, c1, c2); } System.out.print(s); } public static String replace(String s, int l, int r, char c1, char c2) { StringBuilder sb = new StringBuilder(s); for (int i = l - 1; i < r; i++) { if (sb.charAt(i) == c1) { sb.setCharAt(i, c2); } } return sb.toString(); } }