import java.io.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args)  throws Exception {
        FastScanner fs = new FastScanner(System.in);
        
        int n = fs.nextInt();
        int k = fs.nextInt();
        String s = fs.nextLine();    // 读含 'I' 的整行

        int r1 = 0;
        int r2 = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'I') {
                r1 = i - 1;
                r2 = i + 1;
                break;
            }
        }
        for (int i = 0; i < k; i++) {
            char c = fs.nextLine().charAt(0);
            if (c == 'd') {
                if (r2 < s.length())r2++;
            } else {
                if (r1 >= 0 && r2 < s.length() && s.charAt(r1) == '(' && s.charAt(r2) == ')') {
                    r1--;
                    r2++;
                } else {
                    if (r1 >= 0)r1--;
                }
            }
        }
        StringBuilder out = new StringBuilder(s.length());
        out.append(s, 0, r1 + 1);
        out.append('I');
        out.append(s, r2, s.length());
        System.out.println(out);
    }

    // -------- FastScanner: super fast token/line reader --------
    static final class FastScanner {
        private final InputStream in;
        private final byte[] buffer = new byte[1 << 16];
        private int ptr = 0, len = 0;

        FastScanner(InputStream is) {
            this.in = is;
        }

        private int read() throws IOException {
            if (ptr >= len) {
                len = in.read(buffer);
                ptr = 0;
                if (len <= 0) return -1;
            }
            return buffer[ptr++];
        }

        int nextInt() throws IOException {
            int c, sgn = 1, x = 0;
            do c = read();
            while (c <= ' '); // skip spaces
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            while (c > ' ') {
                x = x * 10 + (c - '0');
                c = read();
            }
            return x * sgn;
        }

        // read a whole line (without trailing \r)
        String nextLine() throws IOException {
            StringBuilder sb = new StringBuilder();
            int c = read();
            // consume pending '\n' from previous token read
            while (c == '\n' || c == '\r') c = read();
            for (; c != -1 && c != '\n' && c != '\r'; c = read()) sb.append((char)c);
            return sb.toString();
        }

        // get first non-space char of the next token/line
        char nextNonSpaceChar() throws IOException {
            int c;
            do c = read();
            while (c != -1 && c <= ' ');
            return (char)(c == -1 ? 0 : c);
        }
    }
}