// Задача "Преобразователь строк"
// 12-ая Интернет-олимпиада сезона 2006-2007, базовый уровень
// Автор задачи: Федор Царев, tsarev@rain.ifmo.ru
// Автор решения: Федор Царев, tsarev@rain.ifmo.ru

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

public class morpher_ft implements Runnable {

	private Scanner in;
	private PrintWriter out;
	String fname = "morpher";

	private void myAssert(boolean e, String message) {
		if (!e) {
			throw new Error("Assertion failure!!! " + message);
		}
	}

	public void sort(char[] s, int l, int r) {
		int[] cnt = new int[26];
		for (int i = l; i <= r; i++) {
			cnt[s[i] - 'a']++;
		}
		int cur = l;
		for (int i = 0; i < 26; i++) {
			char ch = (char)('a' + i);
			for (int j = 0; j < cnt[i]; j++) {
				s[cur++] = ch;
			}
		}
	} 

	public void reverse(char[] s, int l, int r) {
		char[] sc = s.clone();
		int len = r - l + 1;
		for (int i = 0; i < len; i++) {
			s[l + i] = sc[r - i];
		}
	}

	public void solve() {
		String s = in.next();
		int m = s.length();
		myAssert(1 <= m && m <= 200, "m < 1 || m > 200");
		for (int i = 0; i < m; i++) {
			char ch = s.charAt(i);
			myAssert('a' <= ch && ch <= 'z', i + "-th character of s is not a small letter");
		}
		int n = in.nextInt();
		myAssert(1 <= n && n <= 200, "n < 1 || n > 200");
		char[] sa = s.toCharArray();
		for (int i = 0; i < n; i++) {
			String op = in.next();
			int l = in.nextInt();
			int r = in.nextInt();
			myAssert(1 <= l && l <= r && r <= m, "Must be: 1 <= l <= r <= m");
			if ("S".equals(op)) {
				sort(sa, l - 1, r - 1);
			} else if ("R".equals(op)) {
				reverse(sa, l - 1, r - 1);
			} else {
				myAssert(false, "Unknown operation: " + op);
			}
		}
		for (int i = 0; i < m; i++) {
			out.print(sa[i]);
		}
		out.println();
	}

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}		
	}

	public morpher_ft() {
		try {
			in = new Scanner(new File(fname + ".in"));
			out = new PrintWriter(new File(fname + ".out"));
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}


	public static void main(String[] args) {
		new Thread(new morpher_ft()).start();
	}

}