import java.io.*;
import java.util.*;

public class Checker {

/*
проверяет корректность аутпута. не смотрит на оптимальность ответа
*/

	Scanner in;
	Scanner out;
	PrintWriter log;

                                      
	void solve() {
		char s[] = in.nextLine().toCharArray();
		char res[] = new char[s.length];
		int nActions = out.nextInt();
		int currIdx = 0;
		for (int i = 0; i < nActions; i++) {
			String cmd = out.next();
			if (!cmd.equals("letter")) {
				asserT(cmd.equals("copy"), "JOPA");
				int lowIdx = out.nextInt();
				int highIdx = out.nextInt();
				asserT(lowIdx < highIdx, "Wrong lowIdx < highIdx");
				asserT(highIdx < currIdx, "Wrong highIdx < currIdx");
            for (int j = lowIdx; j <= highIdx; j++) {
            	res[currIdx] = s[j];
            	asserT(res[currIdx] == s[currIdx], "Incorrect symbol placed: " + lowIdx + " " + highIdx);
            	currIdx++;
            }
			} else {
				res[currIdx] = s[currIdx];
				currIdx++;
			}
			/*
			for (int j = 0; j < currIdx; j++) {
				log.print(res[j]);
			}
			log.println();
			for (int j = 0; j < currIdx; j++) {
				log.print(s[j]);
			}
			log.println();
         */
		}			
		asserT(currIdx == s.length, "incorrect all size");
		log.println("end test");
   }

   void asserT(boolean e, String err) {
   	if (!e){
   		log.println(err);   		
   	}
   }

	void run(String filename){
		try {
			in = new Scanner(new FileReader(filename + ".in"));
			out = new Scanner(new FileReader(filename + ".outZ"));
			log = new PrintWriter(filename + ".logZ");
		} catch (IOException e) {
			throw new Error();
		}
		try {
			solve();
		} finally {
			log.close();
		}
	}

	void checkAll(){
		int low = 0;
		int high = 13;
		for (int i = low; i <= high; i++) {
			run(i + "");
		} 
	}

	public static void main(String []args) {
		new Checker().checkAll();
	}
}