import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNext()) { // 注意 while 处理多个 case String str = in.next(); // 读取输入的字符串 int n = in.nextInt(); // 读取操作指令的数量 String[] instruction = new String[n]; // 存储操作指令的数组 for (int i = 0; i < n; i++) { instruction[i] = in.next(); // 逐个读取操作指令 } for (int i = 0; i < n; i++) { int start = instruction[i].charAt(1) - '0'; // 获取操作指令中的起始位置 int len = instruction[i].charAt(2) - '0'; // 获取操作指令中的长度 if (instruction[i].charAt(0) == '1') { // 如果是替换操作 String replace = instruction[i].substring(3); // 获取替换的字符串 String ss = str.substring(0, start) + replace + str.substring(start + len); // 执行替换操作 System.out.println(ss); // 输出结果 str = ss; // 更新原始字符串 } else { // 如果是反转操作 String replace = new StringBuilder(str.substring(start, start + len)).reverse().toString(); // 获取反转后的字符串 String ss = str.substring(0, start) + replace + str.substring(start + len); // 执行反转操作 System.out.println(ss); // 输出结果 str = ss; // 更新原始字符串 } } } } }