#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct chars
{
    chars * left;
    chars * right;
    chars * pair;
    char type;
};
chars * new_char()
{
    static chars a[1000005];
    static int top=0;
    return &a[top++];
}
chars * c[500005];
char a[500005],b[500005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    p--;
    scanf("%s",a);
    int i;
    static int que[500005];
    int top=0;
    chars * start=new_char();
    chars * end=new_char();
    for (i=0;i<n;i++)
    {
        c[i]=new_char();
        c[i]->type=a[i];
        if (a[i]=='(')
        {
            que[top++]=i;
        }
        else
        {
            top--;
            c[que[top]]->pair=c[i];
            c[i]->pair=c[que[top]];
        }
        if (i!=0) c[i]->left=c[i-1];
        if (i!=0) c[i-1]->right=c[i];
    }
    c[0]->left=start;
    start->right=c[0];
    c[n-1]->right=end;
    end->left=c[n-1];
    chars * now=c[p];
    scanf("%s",b);
    for (i=0;i<m;i++)
    {
        if (b[i]=='L')
        {
            now=now->left;
        }
        else if (b[i]=='R')
        {
            now=now->right;
        }
        else
        {
            chars * t=now->pair;
            if (now->type==')') swap(now,t);
            now->left->right=t->right;
            t->right->left=now->left;
            now=t->right;
        }
    }
    now=start;
    for (;;)
    {
        now=now->right;
        if (now==end) break;
        printf("%c",now->type);
    }
    printf("\n");
    return 0;
}


#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct chars
{
    chars * left;
    chars * right;
    chars * pair;
    char type;
};
chars * new_char()
{
    static chars a[1000005];
    static int top=0;
    return &a[top++];
}
chars * c[500005];
char a[500005],b[500005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    p--;
    scanf("%s",a);
    int i;
    static int que[500005];
    int top=0;
    chars * start=new_char();
    chars * end=new_char();
    for (i=0;i<n;i++)
    {
        c[i]=new_char();
        c[i]->type=a[i];
        if (a[i]=='(')
        {
            que[top++]=i;
        }
        else
        {
            top--;
            c[que[top]]->pair=c[i];
            c[i]->pair=c[que[top]];
        }
        if (i!=0) c[i]->left=c[i-1];
        if (i!=0) c[i-1]->right=c[i];
    }
    c[0]->left=start;
    start->right=c[0];
    c[n-1]->right=end;
    end->left=c[n-1];
    chars * now=c[p];
    scanf("%s",b);
    for (i=0;i<m;i++)
    {
        if (b[i]=='L')
        {
            now=now->left;
        }
        else if (b[i]=='R')
        {
            now=now->right;
        }
        else
        {
            chars * t=now->pair;
            if (now->type==')') swap(now,t);
            now->left->right=t->right;
            t->right->left=now->left;
            now=t->right;
            if (now==end) now=now->left;
        }
    }
    now=start;
    for (;;)
    {
        now=now->right;
        if (now==end) break;
        printf("%c",now->type);
    }
    printf("\n");
    return 0;
}


#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct chars
{
    chars * left;
    chars * right;
    chars * pair;
    char type;
};
chars * new_char()
{
    static chars a[1000005];
    static int top=0;
    return &a[top++];
}
chars * c[500005];
char a[500005],b[500005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m,p;
    scanf("%d%d%d",&n,&m,&p);
    scanf("%s",a);
    int i;
    static int que[500005];
    int top=0;
    chars * start=new_char();
    chars * end=new_char();
    for (i=0;i<n;i++)
    {
        c[i]=new_char();
        c[i]->type=a[i];
        if (a[i]=='(')
        {
            que[top++]=i;
        }
        else
        {
            top--;
            c[que[top]]->pair=c[i];
            c[i]->pair=c[que[top]];
        }
        if (i!=0) c[i]->left=c[i-1];
        if (i!=0) c[i-1]->right=c[i];
    }
    c[0]->left=start;
    start->right=c[0];
    c[n-1]->right=end;
    end->left=c[n-1];
    chars * now=c[p];
    scanf("%s",b);
    for (i=0;i<m;i++)
    {
        if (b[i]=='L')
        {
            now=now->left;
        }
        else if (b[i]=='R')
        {
            now=now->right;
        }
        else
        {
            chars * t=now->pair;
            if (now->type==')') swap(now,t);
            now->left->right=t->right;
            t->right->left=now->left;
            now=t->right;
        }
    }
    now=start;
    for (;;)
    {
        now=now->right;
        if (now==end) break;
        printf("%c",now->type);
    }
    printf("\n");
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

const int MOD = 1000000007;

int l[523456];
int r[523456];

set<pair<int, int> > stLeft;
int n, k;

void deleteFromLeft(int & L, int & R)
{
    set<pair<int, int> > ::iterator it = stLeft.lower_bound(make_pair(L, R));

    if(it == stLeft.begin())
    {
        stLeft.insert(make_pair(L, R));
        return;
    }
    --it;
    if(it->second == L-1)
    {
        pair<int, int> pp = make_pair(it->first, R);
        stLeft.erase(pp);
        stLeft.insert(pp);
        L = pp.first;
        R = pp.second;
    }
}
void deleteFromRight(int & L, int & R)
{
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, R));
    if(it == stLeft.end())
    {
        stLeft.insert(make_pair(L, R));
        return;
    }
    --it;
    if(it->first == R+1)
    {
        pair<int, int> pp = make_pair(L, it->second);
        stLeft.erase(pp);
        stLeft.insert(pp);
        L = pp.first;
        R = pp.second;
    }
}

void checkL(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 1e9));
    if(it == stLeft.end())
        --it;
    if(it->first == 1)
        m = it->second + 1;
    else
        m = it->first - 1;
}
void checkR(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 0));
    if(it == stLeft.end())
        --it;
    if(it->second == n)
        m = it->first - 1;
    else
        m = it->second + 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int m;
    cin >> n >> k >> m;
    string ss;
    string s;
    cin >> s;
    ss = s;
    int sum = 0;
    stack<int> st;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '(')
            st.push(i);
        else
        {
            l[i+1] = st.top()+1;
            r[st.top()+1] = i+1;
            st.pop();
        }
    }

    cin >> s;

    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'L')
        {
            --m;
            checkL(m);
        } else if(s[i] == 'R')
        {
            ++m;
            checkR(m);
        }
        else
        {
            int L, R;
            if(r[m])
            {
                L = m;
                R = r[m];
            }
            else
            {
                L = l[m];
                R = m;
            }
            deleteFromLeft(L, R);
            deleteFromRight(L, R);
            checkR(m);
        }
    }
    vector<bool> used(n,1);
    for(set<pair<int, int> >::iterator it = stLeft.begin(); it != stLeft.end(); ++it)
    {
        int L = it->first;
        int R = it->second;
        for(int i = L-1; i < R; ++i)
            used[i] = 0;
    }
    for(int i = 0; i < n; ++i)
        if(used[i])
            cout << ss[i];
    cout << endl;

	return 0;
}

/*

8 4 5
(())()()
D

8 4 5
(())()()
RDLD

*/


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

const int MOD = 1000000007;

int l[523456];
int r[523456];

set<pair<int, int> > stLeft;
int n, k;

void deleteFromLeft(int & L, int & R)
{
    set<pair<int, int> > ::iterator it = stLeft.lower_bound(make_pair(L, R));

    if(it == stLeft.begin())
        return;
    --it;
    if(it->second == L-1)
    {
        pair<int, int> pp = make_pair(it->first, R);
        stLeft.erase(it);
        L = pp.first;
        R = pp.second;
    }
}
void deleteFromRight(int & L, int & R)
{
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, R));
    if(it == stLeft.end())
        return;

    if(it->first == R+1)
    {
        pair<int, int> pp = make_pair(L, it->second);
        stLeft.erase(it);
        L = pp.first;
        R = pp.second;
    }
}

void checkL(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 1e9));
    if(it != stLeft.begin())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->first == 1)
        m = it->second + 1;
    else
        m = it->first - 1;
}
void checkR(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 1e9));
    if(it != stLeft.begin())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->second == n)
        m = it->first - 1;
    else
        m = it->second + 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int m;
    cin >> n >> k >> m;
    string ss;
    string s;
    cin >> s;
    ss = s;
    int sum = 0;
    stack<int> st;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '(')
            st.push(i);
        else
        {
            l[i+1] = st.top()+1;
            r[st.top()+1] = i+1;
            st.pop();
        }
    }

    cin >> s;

    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'L')
        {
            --m;
            checkL(m);
        } else if(s[i] == 'R')
        {
            ++m;
            checkR(m);
        }
        else
        {
            int L, R;
            if(r[m])
            {
                L = m;
                R = r[m];
            }
            else
            {
                L = l[m];
                R = m;
            }
            vector<pair<int, int> > neededToDel;
            set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, 1e9));
            while(it != stLeft.end() && it->first < R)
            {
                neededToDel.push_back(*it);
                ++it;
            }
            for(int j = 0; j < neededToDel.size(); ++j)
                stLeft.erase(neededToDel[j]);
            deleteFromLeft(L, R);
            deleteFromRight(L, R);
            stLeft.insert(make_pair(L, R));
            checkR(m);
        }
    }
    vector<bool> used(ss.size(), 1);
    for(set<pair<int, int> >::iterator it = stLeft.begin(); it != stLeft.end(); ++it)
    {
        int L = it->first;
        int R = it->second;
        for(int i = L-1; i < R; ++i)
        {
            if(used[i] == 0)
                cout << "PLOHO\n";
            used[i] = 0;
        }
    }
    for(int i = 0; i < ss.size(); ++i)
        if(used[i])
            cout << ss[i];
    cout << endl;

	return 0;
}

/*

12 1 4
((())(()()))
DRRRRDLDD
(()())

6 4 1
(())
RDLR
()

8 4 5
(())()()
D

8 4 5
(())()()
RDLD

*/


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

const int MOD = 1000000007;

int l[523456];
int r[523456];

set<pair<int, int> > stLeft;
int n, k;

void deleteFromLeft(int & L, int & R)
{
    set<pair<int, int> > ::iterator it = stLeft.lower_bound(make_pair(L, R));

    if(it == stLeft.begin())
        return;
    --it;
    if(it->second == L-1)
    {
        pair<int, int> pp = make_pair(it->first, R);
        stLeft.erase(it);
        L = pp.first;
        R = pp.second;
    }
}
void deleteFromRight(int & L, int & R)
{
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, R));
    if(it == stLeft.end())
        return;

    if(it->first == R+1)
    {
        pair<int, int> pp = make_pair(L, it->second);
        stLeft.erase(it);
        L = pp.first;
        R = pp.second;
    }
}

void checkL(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 1e9));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->first == 1)
        m = it->second + 1;
    else
        m = it->first - 1;
}
void checkR(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 0));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->second == n)
        m = it->first - 1;
    else
        m = it->second + 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int m;
    cin >> n >> k >> m;
    string ss;
    string s;
    cin >> s;
    ss = s;
    int sum = 0;
    stack<int> st;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '(')
            st.push(i);
        else
        {
            l[i+1] = st.top()+1;
            r[st.top()+1] = i+1;
            st.pop();
        }
    }

    cin >> s;

    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'L')
        {
            --m;
            checkL(m);
        } else if(s[i] == 'R')
        {
            ++m;
            checkR(m);
        }
        else
        {
            int L, R;
            if(r[m])
            {
                L = m;
                R = r[m];
            }
            else
            {
                L = l[m];
                R = m;
            }
            vector<pair<int, int> > neededToDel;
            set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, 1e9));
            while(it != stLeft.end() && it->first < R)
            {
                neededToDel.push_back(*it);
                ++it;
            }
            for(int j = 0; j < neededToDel.size(); ++j)
                stLeft.erase(neededToDel[j]);
            deleteFromLeft(L, R);
            deleteFromRight(L, R);
            stLeft.insert(make_pair(L, R));
            checkR(m);
        }
    }
    vector<bool> used(ss.size(), 1);
    for(set<pair<int, int> >::iterator it = stLeft.begin(); it != stLeft.end(); ++it)
    {
        int L = it->first;
        int R = it->second;
        for(int i = L-1; i < R; ++i)
        {
            if(used[i] == 0)
                cout << "PLOHO\n";
            used[i] = 0;
        }
    }
    for(int i = 0; i < ss.size(); ++i)
        if(used[i])
            cout << ss[i];
    cout << endl;

	return 0;
}

/*

12 1 4
((())(()()))
DRRRRDLDD
(()())

6 4 1
(())
RDLR
()

8 4 5
(())()()
D

8 4 5
(())()()
RDLD

*/


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

const int MOD = 1000000007;

int l[523456];
int r[523456];

set<pair<int, int> > stLeft;
int n, k;

void deleteFromLeft(int & L, int & R)
{
    set<pair<int, int> > ::iterator it = stLeft.lower_bound(make_pair(L, R));

    if(it == stLeft.begin())
    {
        stLeft.insert(make_pair(L, R));
        return;
    }
    --it;
    if(it->second == L-1)
    {
        pair<int, int> pp = make_pair(it->first, R);
        stLeft.erase(it);
        stLeft.insert(pp);
        L = pp.first;
        R = pp.second;
    }
}
void deleteFromRight(int & L, int & R)
{
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, R));
    if(it == stLeft.end())
    {
        stLeft.insert(make_pair(L, R));
        return;
    }
    --it;
    if(it->first == R+1)
    {
        pair<int, int> pp = make_pair(L, it->second);
        stLeft.erase(it);
        stLeft.insert(pp);
        L = pp.first;
        R = pp.second;
    }
}

void checkL(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 1e9));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->first == 1)
        m = it->second + 1;
    else
        m = it->first - 1;
}
void checkR(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 0));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->second == n)
        m = it->first - 1;
    else
        m = it->second + 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int m;
    cin >> n >> k >> m;
    string ss;
    string s;
    cin >> s;
    ss = s;
    int sum = 0;
    stack<int> st;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '(')
            st.push(i);
        else
        {
            l[i+1] = st.top()+1;
            r[st.top()+1] = i+1;
            st.pop();
        }
    }

    cin >> s;

    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'L')
        {
            --m;
            checkL(m);
        } else if(s[i] == 'R')
        {
            ++m;
            checkR(m);
        }
        else
        {
            int L, R;
            if(r[m])
            {
                L = m;
                R = r[m];
            }
            else
            {
                L = l[m];
                R = m;
            }
            vector<pair<int, int> > neededToDel;
            set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, 1e9));
            while(it != stLeft.end() && it->first < R)
            {
                neededToDel.push_back(*it);
                ++it;
            }
            for(int j = 0; j < neededToDel.size(); ++j)
                stLeft.erase(neededToDel[j]);
            deleteFromLeft(L, R);
            deleteFromRight(L, R);
            checkR(m);
        }
    }
    vector<bool> used(ss.size(),1);
    for(set<pair<int, int> >::iterator it = stLeft.begin(); it != stLeft.end(); ++it)
    {
        int L = it->first;
        int R = it->second;
        for(int i = L-1; i < R; ++i)
            used[i] = 0;
    }
    for(int i = 0; i < n; ++i)
        if(used[i])
            cout << ss[i];
    cout << endl;

	return 0;
}

/*

12 1 4
((())(()()))
DDRRRRDDLDD

6 4 1
(())
RDLR
()

8 4 5
(())()()
D

8 4 5
(())()()
RDLD

*/


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

const int MOD = 1000000007;

int l[523456];
int r[523456];

set<pair<int, int> > stLeft;
int n, k;

void deleteFromLeft(int & L, int & R)
{
    set<pair<int, int> > ::iterator it = stLeft.lower_bound(make_pair(L, R));

    if(it == stLeft.begin())
    {
        stLeft.insert(make_pair(L, R));
        return;
    }
    --it;
    if(it->second == L-1)
    {
        pair<int, int> pp = make_pair(it->first, R);
        stLeft.erase(pp);
        stLeft.insert(pp);
        L = pp.first;
        R = pp.second;
    }
}
void deleteFromRight(int & L, int & R)
{
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, R));
    if(it == stLeft.end())
    {
        stLeft.insert(make_pair(L, R));
        return;
    }
    --it;
    if(it->first == R+1)
    {
        pair<int, int> pp = make_pair(L, it->second);
        stLeft.erase(pp);
        stLeft.insert(pp);
        L = pp.first;
        R = pp.second;
    }
}

void checkL(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 1e9));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->first == 1)
        m = it->second + 1;
    else
        m = it->first - 1;
}
void checkR(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 0));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->second == n)
        m = it->first - 1;
    else
        m = it->second + 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int m;
    cin >> n >> k >> m;
    string ss;
    string s;
    cin >> s;
    ss = s;
    int sum = 0;
    stack<int> st;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '(')
            st.push(i);
        else
        {
            l[i+1] = st.top()+1;
            r[st.top()+1] = i+1;
            st.pop();
        }
    }

    cin >> s;

    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'L')
        {
            --m;
            checkL(m);
        } else if(s[i] == 'R')
        {
            ++m;
            checkR(m);
        }
        else
        {
            int L, R;
            if(r[m])
            {
                L = m;
                R = r[m];
            }
            else
            {
                L = l[m];
                R = m;
            }
            vector<pair<int, int> > neededToDel;
            set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, 1e9));
            while(it != stLeft.end() && it->first < R)
            {
                neededToDel.push_back(*it);
                ++it;
            }
            for(int j = 0; j < neededToDel.size(); ++j)
                stLeft.erase(neededToDel[j]);
            deleteFromLeft(L, R);
            deleteFromRight(L, R);
            checkR(m);
        }
    }
    vector<bool> used(ss.size(),1);
    for(set<pair<int, int> >::iterator it = stLeft.begin(); it != stLeft.end(); ++it)
    {
        int L = it->first;
        int R = it->second;
        for(int i = L-1; i < R; ++i)
            used[i] = 0;
    }
    for(int i = 0; i < n; ++i)
        if(used[i])
            cout << ss[i];
    cout << endl;

	return 0;
}

/*

6 4 1
(())
RDLR
()

8 4 5
(())()()
D

8 4 5
(())()()
RDLD

*/


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

const int MOD = 1000000007;

int l[523456];
int r[523456];

set<pair<int, int> > stLeft;
int n, k;

void deleteFromLeft(int & L, int & R)
{
    set<pair<int, int> > ::iterator it = stLeft.lower_bound(make_pair(L, R));

    if(it == stLeft.begin())
        return;
    --it;
    if(it->second == L-1)
    {
        pair<int, int> pp = make_pair(it->first, R);
        stLeft.erase(it);
        L = pp.first;
        R = pp.second;
    }
}
void deleteFromRight(int & L, int & R)
{
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, R));
    if(it == stLeft.end())
        return;

    if(it->first == R+1)
    {
        pair<int, int> pp = make_pair(L, it->second);
        stLeft.erase(it);
        L = pp.first;
        R = pp.second;
    }
}

void checkL(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 1e9));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->first == 1)
        m = it->second + 1;
    else
        m = it->first - 1;
}
void checkR(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 0));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->second == n)
        m = it->first - 1;
    else
        m = it->second + 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int m;
    cin >> n >> k >> m;
    string ss;
    string s;
    cin >> s;
    ss = s;
    int sum = 0;
    stack<int> st;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '(')
            st.push(i);
        else
        {
            l[i+1] = st.top()+1;
            r[st.top()+1] = i+1;
            st.pop();
        }
    }

    cin >> s;

    for(int i = 0; i < s.size(); ++i)
    {
        int mm = m;
        checkR(mm);
        if(mm != m)
        {
            cout << "TUT " << i << endl;
        }
        if(s[i] == 'L')
        {
            --m;
            checkL(m);
        } else if(s[i] == 'R')
        {
            ++m;
            checkR(m);
        }
        else
        {
            int L, R;
            if(r[m])
            {
                L = m;
                R = r[m];
            }
            else
            {
                L = l[m];
                R = m;
            }
            vector<pair<int, int> > neededToDel;
            set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, 1e9));
            while(it != stLeft.end() && it->first < R)
            {
                neededToDel.push_back(*it);
                ++it;
            }
            for(int j = 0; j < neededToDel.size(); ++j)
                stLeft.erase(neededToDel[j]);
            deleteFromLeft(L, R);
            deleteFromRight(L, R);
            stLeft.insert(make_pair(L, R));
            checkR(m);
        }
    }
    vector<bool> used(ss.size(),1);
    for(set<pair<int, int> >::iterator it = stLeft.begin(); it != stLeft.end(); ++it)
    {
        int L = it->first;
        int R = it->second;
        for(int i = L-1; i < R; ++i)
        {
            if(used[i] == 0)
                cout << "PLOHO\n";
            used[i] = 0;
        }
    }
    for(int i = 0; i < ss.size(); ++i)
        if(used[i])
            cout << ss[i];
    cout << endl;

	return 0;
}

/*

12 1 4
((())(()()))
DRRRRDLDD
(()())

6 4 1
(())
RDLR
()

8 4 5
(())()()
D

8 4 5
(())()()
RDLD

*/


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

const int MOD = 1000000007;

int l[523456];
int r[523456];

set<pair<int, int> > stLeft;
int n, k;

void deleteFromLeft(int & L, int & R)
{
    set<pair<int, int> > ::iterator it = stLeft.lower_bound(make_pair(L, R));

    if(it == stLeft.begin())
        return;
    --it;
    if(it->second == L-1)
    {
        pair<int, int> pp = make_pair(it->first, R);
        stLeft.erase(it);
        L = pp.first;
        R = pp.second;
    }
}
void deleteFromRight(int & L, int & R)
{
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, R));
    if(it == stLeft.end())
        return;

    if(it->first == R+1)
    {
        pair<int, int> pp = make_pair(L, it->second);
        stLeft.erase(it);
        L = pp.first;
        R = pp.second;
    }
}

void checkL(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 1e9));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->first == 1)
        m = it->second + 1;
    else
        m = it->first - 1;
}
void checkR(int & m)
{
    if(stLeft.size() == 0)
        return;
    set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(m, 0));
    if(it == stLeft.end())
        --it;
    if(it->first > m || it->second < m)
        return;
    if(it->second == n)
        m = it->first - 1;
    else
        m = it->second + 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    int m;
    cin >> n >> k >> m;
    string ss;
    string s;
    cin >> s;
    ss = s;
    int sum = 0;
    stack<int> st;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '(')
            st.push(i);
        else
        {
            l[i+1] = st.top()+1;
            r[st.top()+1] = i+1;
            st.pop();
        }
    }

    cin >> s;

    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == 'L')
        {
            --m;
            checkL(m);
        } else if(s[i] == 'R')
        {
            ++m;
            checkR(m);
        }
        else
        {
            int L, R;
            if(r[m])
            {
                L = m;
                R = r[m];
            }
            else
            {
                L = l[m];
                R = m;
            }
            vector<pair<int, int> > neededToDel;
            set<pair<int, int> >::iterator it = stLeft.lower_bound(make_pair(L, 1e9));
            while(it != stLeft.end() && it->first < R)
            {
                neededToDel.push_back(*it);
                ++it;
            }
            for(int j = 0; j < neededToDel.size(); ++j)
                stLeft.erase(neededToDel[j]);
            deleteFromLeft(L, R);
            deleteFromRight(L, R);
            stLeft.insert(make_pair(L, R));
            checkR(m);
        }
    }
    vector<bool> used(ss.size(),1);
    for(set<pair<int, int> >::iterator it = stLeft.begin(); it != stLeft.end(); ++it)
    {
        int L = it->first;
        int R = it->second;
        for(int i = L-1; i < R; ++i)
            used[i] = 0;
    }
    for(int i = 0; i < n; ++i)
        if(used[i])
            cout << ss[i];
    cout << endl;

	return 0;
}

/*

12 1 4
((())(()()))
DD

6 4 1
(())
RDLR
()

8 4 5
(())()()
D

8 4 5
(())()()
RDLD

*/


#pragma comment(linker, "/STACK:134217728")
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>
#include <functional>
#include <cmath>
#include <time.h>

using namespace std;

typedef long long LL;

const int MOD = (int)1e9 + 7;

char s[500001];
char q[500001];

int n, m, p;

int st[250000];
int sz = 0;

int mate[500000];

int main()
{
	scanf("%d%d%d", &n, &m, &p);
	p--;

	scanf("%s", s);

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '(')
			st[sz++] = i;
		else
		{
			int top = st[--sz];
			mate[top] = i;
			mate[i] = top;
		}
	}

	scanf("%s", q);

	set<int> S;
	for (int i = 0; i < n; ++i)
		S.insert(i);

	set<int> :: iterator it = S.find(p);

	for (int i = 0; i < m; ++i)
	{
		if (q[i] == 'L')
			it--;
		if (q[i] == 'R')
			it++;
		if (q[i] == 'D')
		{
			int last = *it;

			set<int> ::iterator del;

			if (*it < mate[*it])
			{
				del = it;
				it = S.find(mate[*it]);
			}
			else
				del = S.find(mate[*it]);
			while (del != it)
			{
				set<int> ::iterator next = del;
				next++;
				S.erase(del);
				del = next;
			}

			S.erase(del);

			it = S.upper_bound(last);
			if (it == S.end())
				it--;
		}
	}

	for (set<int> :: iterator it = S.begin(); it != S.end(); ++it)
		printf("%c", s[*it]);
	printf("\n");
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <stack>

#define ll long long
using namespace std;

typedef struct Node
{
	Node* next;
	Node* last;
	Node* partner;
	char value;
};

int main()
{
	int n,m,p;
	cin >> n >> m >> p;
	vector<Node*> originalSec;
	stack<int> opened;
	vector<char> operations;

	for (int i = 0; i < n; i++)
	{
		char pos;
		cin >> pos;
		Node *nod = new Node();
		nod->value = pos;
		if(i !=0)
		{
			originalSec[i-1]->next = nod;
			nod->last = originalSec[i-1];
		}
		if(pos == ')')
		{
			originalSec[opened.top()]->partner = nod;
			nod->partner = originalSec[opened.top()];
			opened.pop();
		}
		else if(pos == '(')
		{
			opened.push(i);
		}

		originalSec.push_back(nod);
	}

	for (int i = 0; i < m; i++)
	{
		char tmp;
		cin >> tmp;
		operations.push_back(tmp);
	}

	Node* curr = originalSec[ p-1];
	for (int i = 0; i < operations.size(); i++)
	{
		if(operations[i] == 'D')
		{
			if(curr->value == ')')
			{
				Node* tmp1 = curr->partner->last;
				Node* tmp2 = curr->next;

				if(tmp1 != NULL)
				{
					tmp1->next = tmp2;
				}
				if(tmp2 != NULL)
				{
					tmp2->last = tmp1;
					curr = tmp2;
				}
				else
				{
					curr = tmp1;
				}
			}
			else
			{
				Node* tmp1 = curr->partner->next;
				Node* tmp2 = curr->last;

				if(tmp2 != NULL)
				{
					tmp2->next = tmp1;
				}
				if(tmp1 != NULL)
				{
					tmp1->last = tmp2;
					curr = tmp1;
				}
				else
				{
					curr = tmp2;
				}
			}
		}
		else if(operations[i] == 'R')
		{
			curr = curr->next;
		}
		else if(operations[i] == 'L')
		{
			curr = curr->last;
		}
	}

	Node *pos = curr;
	Node *start = pos;
	while (pos)
	{
		start = pos;
		pos = pos->last;
	}

	while (start)
	{
		cout << start->value;
		start = start->next;
	}
	cout << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int pres[500010], pos[500010], l[500010], r[500010];

int main()
{
	long long n, k, ans = 0, m, p, start = 0;
	cin >> n >> m >> p;
	--p;

	for (int i = 0; i < n; ++i)
	{
		l[i] = i - 1;
		r[i] = i + 1;
	}

	string s;
	cin >> s;

	stack <int> sk;

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '(')
			sk.push(i);
		else
		{
			pos[sk.top()] = i;
			pres[i] = sk.top();
			sk.pop();
		}
	}

	for (int i = 0; i < m; ++i)
	{
		char cur;
		cin >> cur;

		if (cur == 'R')
			p = r[p];
		else
		if (cur == 'L')
			p = l[p];
		else
		{
			if (s[p] == '(')
			{
				if (l[p] == -1)
				{
					l[r[pos[p]]] = -1;
					start = r[pos[p]];
					l[p] = -2;
					p = start;
				}
				else
				{
					if (r[pos[p]] != n)
					{
						l[r[pos[p]]] = l[p];
						r[l[p]] = r[pos[p]];
						p = r[pos[p]];
					}
					else
					{
						r[l[p]] = n;
						p = l[p];
					}
				}
			}
			else
			{
				if (r[p] == n)
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = n;
						r[p] = n + 1;
						p = l[pres[p]];
					}
					else
					{

					}
				}
				else
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = r[p];
						l[r[p]] = l[pres[p]];
						p = r[p];
					}
					else
					{
						start = r[p];
						l[r[p]] = -1;
						p = start;
					}
				}
			}
		}

		/*int curPos = start;

		while (curPos != n)
		{
			cout << s[curPos];
			curPos = r[curPos];
		}

		cout << endl; */
	}

	int curPos = start;

	while (curPos != n)
	{
		cout << s[curPos];
		curPos = r[curPos];
	}

	cin >> n;
	return 0;

}

/*
12 10 11
(())()()()()
DLRDLRDDLR
*/


#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int pres[500010], pos[500010], l[500010], r[500010];

int main()
{
	long long n, k, ans = 0, m, p, start = 0;
	cin >> n >> m >> p;
	--p;

	for (int i = 0; i < n; ++i)
	{
		l[i] = i - 1;
		r[i] = i + 1;
	}

	string s;
	cin >> s;

	stack <int> sk;

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '(')
			sk.push(i);
		else
		{
			pos[sk.top()] = i;
			pres[i] = sk.top();
			sk.pop();
		}
	}

	for (int i = 0; i < m; ++i)
	{
		char cur;
		cin >> cur;

		if (cur == 'R')
			p = r[p];
		else
		if (cur == 'L')
			p = l[p];
		else
		{
			if (s[p] == '(')
			{
				if (l[p] == -1)
				{
					l[r[pos[p]]] = -1;
					start = r[pos[p]];
					l[p] = -2;
					p = r[pos[p]];
				}
				else
				{
					if (r[pos[p]] != n)
					{
						l[r[pos[p]]] = l[p];
						r[l[p]] = r[pos[p]];
						p = r[pos[p]];
					}
					else
					{
						r[l[p]] = n;
					}
				}
			}
			else
			{
				if (r[p] == n)
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = n;
						r[p] = n + 1;
						p = l[pres[p]];
					}
					else
					{

					}
				}
				else
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = r[p];
						l[r[p]] = l[pres[p]];
						p = r[p];
					}
					else
					{
						start = r[p];
					}
				}
			}
		}
	}

	int curPos = start;

	while (curPos != n)
	{
		cout << s[curPos];
		curPos = r[curPos];
	}

	cin >> n;
	return 0;

}


#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int pres[500010], pos[500010], l[500010], r[500010];

int main()
{
	long long n, k, ans = 0, m, p, start = 0;
	cin >> n >> m >> p;
	--p;

	for (int i = 0; i < n; ++i)
	{
		l[i] = i - 1;
		r[i] = i + 1;
	}

	string s;
	cin >> s;

	stack <int> sk;

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '(')
			sk.push(i);
		else
		{
			pos[sk.top()] = i;
			pres[i] = sk.top();
			sk.pop();
		}
	}

	for (int i = 0; i < m; ++i)
	{
		char cur;
		cin >> cur;

		if (cur == 'R')
			p = r[p];
		else
		if (cur == 'L')
			p = l[p];
		else
		{
			if (s[p] == '(')
			{
				if (l[p] == -1)
				{
					l[r[pos[p]]] = -1;
					start = r[pos[p]];
					l[p] = -2;
					p = start;
				}
				else
				{
					if (r[pos[p]] != n)
					{
						l[r[pos[p]]] = l[p];
						r[l[p]] = r[pos[p]];
						p = r[pos[p]];
					}
					else
					{
						r[l[p]] = n;
						p = l[p];
					}
				}
			}
			else
			{
				if (r[p] == n)
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = n;
						r[p] = n + 1;
						p = l[pres[p]];
					}
					else
					{

					}
				}
				else
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = r[p];
						l[r[p]] = l[pres[p]];
						p = r[p];
					}
					else
					{
						start = r[p];
						l[r[p]] = -1;
						p = start;
					}
				}
			}
		}

		int curPos = start;

		while (curPos != n)
		{
			cout << s[curPos];
			curPos = r[curPos];
		}

		cout << endl;
	}

	int curPos = start;

	while (curPos != n)
	{
		cout << s[curPos];
		curPos = r[curPos];
	}

	cin >> n;
	return 0;

}

/*
12 10 11
(())()()()()
DLRDLRDDLR
*/


#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int pres[500010], pos[500010], l[500010], r[500010];

int main()
{
	long long n, k, ans = 0, m, p, start = 0;
	cin >> n >> m >> p;
	--p;

	for (int i = 0; i < n; ++i)
	{
		l[i] = i - 1;
		r[i] = i + 1;
	}

	string s;
	cin >> s;

	stack <int> sk;

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '(')
			sk.push(i);
		else
		{
			pos[sk.top()] = i;
			pres[i] = sk.top();
			sk.pop();
		}
	}

	for (int i = 0; i < m; ++i)
	{
		char cur;
		cin >> cur;

		if (cur == 'R')
			p = r[p];
		else
		if (cur == 'L')
			p = l[p];
		else
		{
			if (s[p] == '(')
			{
				if (l[p] == -1)
				{
					l[r[pos[p]]] = -1;
					start = r[pos[p]];
					l[p] = -2;
					p = start;
				}
				else
				{
					if (r[pos[p]] != n)
					{
						l[r[pos[p]]] = l[p];
						r[l[p]] = r[pos[p]];
						p = r[pos[p]];
					}
					else
					{
						r[l[p]] = n;
					}
				}
			}
			else
			{
				if (r[p] == n)
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = n;
						r[p] = n + 1;
						p = l[pres[p]];
					}
					else
					{

					}
				}
				else
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = r[p];
						l[r[p]] = l[pres[p]];
						p = r[p];
					}
					else
					{
						start = r[p];
						p = start;
					}
				}
			}
		}
	}

	int curPos = start;

	while (curPos != n)
	{
		cout << s[curPos];
		curPos = r[curPos];
	}

	cin >> n;
	return 0;

}


#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int pres[500010], pos[500010], l[500010], r[500010];

int main()
{
	long long n, k, ans = 0, m, p, start = 0;
	cin >> n >> m >> p;
	--p;

	for (int i = 0; i < n; ++i)
	{
		l[i] = i - 1;
		r[i] = i + 1;
	}

	string s;
	cin >> s;

	stack <int> sk;

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '(')
			sk.push(i);
		else
		{
			pos[sk.top()] = i;
			pres[i] = sk.top();
			sk.pop();
		}
	}

	for (int i = 0; i < m; ++i)
	{
		char cur;
		cin >> cur;

		if (cur == 'R')
			p = r[p];
		else
		if (cur == 'L')
			p = l[p];
		else
		{
			if (s[p] == '(')
			{
				if (l[p] == -1)
				{
					l[r[pos[p]]] = -1;
					start = r[pos[p]];
					l[p] = -2;
					p = r[pos[p]];
				}
				else
				{
					if (r[pos[p]] != n)
					{
						l[r[pos[p]]] = l[p];
						r[l[p]] = r[pos[p]];
						p = r[pos[p]];
					}
					else
					{
						r[l[pres[p]]] = n;
					}
				}
			}
			else
			{
				if (r[p] == n)
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = n;
						r[p] = n + 1;
						p = l[pres[p]];
					}
					else
					{

					}
				}
				else
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = r[p];
						l[r[p]] = l[pres[p]];
						p = r[p];
					}
					else
					{
						start = r[p];
					}
				}
			}
		}
	}

	int curPos = start;

	while (curPos != n)
	{
		cout << s[curPos];
		curPos = r[curPos];
	}

	cin >> n;
	return 0;

}


#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int pres[500010], pos[500010], l[500010], r[500010];

int main()
{
	long long n, k, ans = 0, m, p, start = 0;
	cin >> n >> m >> p;
	--p;

	for (int i = 0; i < n; ++i)
	{
		l[i] = i - 1;
		r[i] = i + 1;
	}

	string s;
	cin >> s;

	stack <int> sk;

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '(')
			sk.push(i);
		else
		{
			pos[sk.top()] = i;
			pres[i] = sk.top();
			sk.pop();
		}
	}

	for (int i = 0; i < m; ++i)
	{
		char cur;
		cin >> cur;

		if (cur == 'R')
			p = r[p];
		else
		if (cur == 'L')
			p = l[p];
		else
		{
			if (s[p] == '(')
			{
				if (l[p] == -1)
				{
					l[r[pos[p]]] = -1;
					start = r[pos[p]];
					l[p] = -2;
					p = start;
				}
				else
				{
					if (r[pos[p]] != n)
					{
						l[r[pos[p]]] = l[p];
						r[l[p]] = r[pos[p]];
						p = r[pos[p]];
					}
					else
					{
						r[l[p]] = n;
					}
				}
			}
			else
			{
				if (r[p] == n)
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = n;
						r[p] = n + 1;
						p = l[pres[p]];
					}
					else
					{

					}
				}
				else
				{
					if (l[pres[p]] != -1)
					{
						r[l[pres[p]]] = r[p];
						l[r[p]] = l[pres[p]];
						p = r[p];
					}
					else
					{
						start = r[p];
						l[r[p]] = -1;
						p = start;
					}
				}
			}
		}
	}

	int curPos = start;

	while (curPos != n)
	{
		cout << s[curPos];
		curPos = r[curPos];
	}

	cin >> n;
	return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <cstdio>
#include <map>
#include <unordered_map>
#include <string>
#include <iomanip>
#include <vector>
#include <memory.h>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <functional>
#include <bitset>
#pragma comment (linker, "/STACK:167177216")
using namespace std;
#define mems(A, val) memset(A, val, sizeof(A))
#define mp(a, b) make_pair(a, b)
#define all(B) (B).begin(), (B).end()
#define forn(it, from, to) for(int it = from; it < to; ++it)
#define forit (it, coll) for(auto it = coll.begin(); it != coll.end(); ++it)
#define sz(a) (int)a.size()
#define pb push_back
const int MAXN = 500 * 1000 + 500;
const double EPS = 1e-9;
typedef long long LL;

int nxt[MAXN], prv[MAXN];

void build(){
	for (int i = 0; i < MAXN; ++i){
		nxt[i] = prv[i] = i;
	}
}

int get_next(int *arr, int v){
	if (arr[v] == v) return v;
	return arr[v] = get_next(arr, arr[v]);
}

int main(int argc, char* argv[]) {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	//freopen("numbers.in", "r", stdin); freopen("numbers.out", "w", stdout);
#endif
	int n, m, p;
	scanf("%d %d %d\n", &n, &m, &p);
	char s[MAXN], path[MAXN];
	cin.getline(s, MAXN);
	cin.getline(path, MAXN);
	build();

	vector<int> st;

	vector<int> pairs_l(n, -1), pairs_r(n, -1);

	for (int i = 0; i < n; ++i){
		if (s[i] == '('){
			st.push_back(i);
		}
		else{
			pairs_l[st.back()] = i;
			pairs_r[i] = st.back();
			st.pop_back();
		}
	}

	for (int i = 0; i < m; ++i){
		if (path[i] == 'R'){
			p = get_next(nxt, p + 1);
		}
		if (path[i] == 'L'){
			p = get_next(prv, p - 1);
		}
		if (path[i] == 'D'){
			int p_i = p - 1;
			int lft, rght;
			if (pairs_l[p_i] != -1){
				lft = p_i;
				rght = pairs_l[p_i];
			}
			else{
				lft = pairs_r[p_i];
				rght = p_i;
			}

			lft++;
			rght++;

			int prv_l = get_next(prv, lft - 1);
			int nxt_r = get_next(nxt, rght + 1);

			int v = prv_l + 1;
			while (v != nxt_r){
				nxt[v] = nxt_r;
				v = get_next(nxt, v + 1);
			}
			v = nxt_r - 1;
			while (v != prv_l){
				prv[v] = prv_l;
				v = get_next(prv, v - 1);
			}

			int pointer = nxt_r;
			if (pointer > n){
				pointer = prv_l;
			}

			p = pointer;
		}
	}

	int v = 0;
	while (v != n + 1){
		v = get_next(nxt, v + 1);
		if (v == n + 1) break;
		printf("%c", s[v - 1]);
	}

	return 0;
}


#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <numeric>

//#include <unordered_set>
//#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
typedef double float64;

template<typename T> T sqr(T x) { return x*x; }
inline uint64 bit(int num) { return 1ull << num; }
#define mp make_pair
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forr(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define forit(i,c) for(i=(c).begin(); i!=(c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define zero(a) memset((a), 0, sizeof(a))

typedef vector<int> vint;
typedef vector<bool> vbool;
typedef vector<int64> vint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

	int n, m, p;
	cin >> n >> m >> p;
	--p;
	string s;
	cin >> s;

	string q;
	cin >> q;

	vint next(n);
	vint prev(n);

	vint pr(n);
	vint st;

	forn(i, n)
	{
		next[i] = i + 1;
		prev[i] = i - 1;

		if (s[i] == '(')
		{
			st.push_back(i);
		}
		else
		{
			int mpr = st.back();
			st.pop_back();
			pr[i] = mpr;
			pr[mpr] = i;
		}
	}

	forn(qq, q.size())
	{
		char cq = q[qq];

		if (cq == 'L')
		{
			p = prev[p];
		}
		else if (cq == 'R')
		{
			p = next[p];
		}
		else
		{
			int a1 = p;
			int a2 = pr[p];
			if (a1 > a2) swap(a1, a2);

			int nnext = next[a2];
			int pprev = prev[a1];

			for (int i = a1; i <= a2;)
			{
				s[i] = '*';
				int ni = next[i];
				next[i] = nnext;
				i = ni;
			}
			for (int i = a2; i >= a1;)
			{
				s[i] = '*';
				int ni = prev[i];
				prev[i] = pprev;
				i = ni;
			}

			if (a1 - 1 >= 0) next[a1 - 1] = nnext;
			if (a2 + 1 < n) prev[a2 + 1] = pprev;

			p = nnext;
			if (nnext >= n)
			{
				p = pprev;
			}
		}

	}

	forn(i, n)
	{
		if (s[i] != '*')
		{
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}


#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <numeric>

//#include <unordered_set>
//#include <unordered_map>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;
typedef double float64;

template<typename T> T sqr(T x) { return x*x; }
inline uint64 bit(int num) { return 1ull << num; }
#define mp make_pair
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define forr(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define forit(i,c) for(i=(c).begin(); i!=(c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define zero(a) memset((a), 0, sizeof(a))

typedef vector<int> vint;
typedef vector<bool> vbool;
typedef vector<int64> vint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

	int n, m, p;
	cin >> n >> m >> p;
	--p;
	string s;
	cin >> s;

	string q;
	cin >> q;

	vint next(n);
	vint prev(n);

	vint pr(n);
	vint st;

	forn(i, n)
	{
		next[i] = i + 1;
		prev[i] = i - 1;

		if (s[i] == '(')
		{
			st.push_back(i);
		}
		else
		{
			int mpr = st.back();
			st.pop_back();
			pr[i] = mpr;
			pr[mpr] = i;
		}
	}

	forn(qq, q.size())
	{
		char cq = q[qq];

		if (cq == 'L')
		{
			p = prev[p];
		}
		else if (cq == 'R')
		{
			p = next[p];
		}
		else
		{
			int a1 = p;
			int a2 = pr[p];
			if (a1 > a2) swap(a1, a2);

			for (int i = a1; i <= a2; i = next[i])
			{
				s[i] = '*';
			}

			int nnext = next[a2];
			int pprev = prev[a1];
			if (pprev >= 0) next[pprev] = nnext;
			if (nnext < n) prev[nnext] = pprev;

			p = nnext;
			if (nnext >= n)
			{
				p = pprev;
			}
			if (p < 0) while (true);
		}

	}

	forn(i, n)
	{
		if (s[i] != '*')
		{
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <stack>
const int maxn = 5e5 + 10;
using namespace std;

int l[maxn],r[maxn],d[maxn];
char str[maxn];
char opr[maxn];
int main(){
	//freopen("in.txt","r",stdin);
	int n,m,k;
	while( scanf("%d %d %d",&n,&m,&k) != EOF ){
		scanf("%s",str+1);
		for( int i = 0; i <= n+1; i++ ){
			l[i] = i - 1;
			r[i] = i + 1;
		}
		stack<int> s;
		for( int i = 1; i <= n; i++ ){
			if( str[i] == '(' ){
				s.push( i );
			}
			else{
				int idx = s.top();
				s.pop();
				d[idx] = i;
				d[i] = idx;
			}
		}
		int pos = k;
		char op;
		scanf("%s",opr);
		for( int i = 0; i < m; i++ ){
			op = opr[i];
			if( op == 'L' ){
				pos = l[pos];
			}
			if( op == 'R' ){
				pos = r[pos];
			}
			if( op == 'D' ){
				int nl,nr;
				if( str[pos] == '(' ){
					nl = l[pos];
					nr = r[d[pos]];
					pos = nr;
				}
				else{
					nl = l[d[pos]];
					nr = r[pos];
					pos = nr;
				}
				//pos = nr;
				r[nl] = nr;
				l[nr] = nl;
				if( pos > n ){
					pos = l[pos];
				}
			}
		}
		for( int i = r[0]; i <= n; i = r[i] ){
			printf("%c",str[i]);
		}
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <stack>
const int maxn = 5e5 + 10;
using namespace std;

int l[maxn],r[maxn],d[maxn];
char str[maxn];
char opr[maxn];
int main(){
	//freopen("in.txt","r",stdin);
	int n,m,k;
	while( scanf("%d %d %d",&n,&m,&k) != EOF ){
		scanf("%s",str+1);
		for( int i = 0; i <= n+1; i++ ){
			l[i] = i - 1;
			r[i] = i + 1;
		}
		stack<int> s;
		for( int i = 1; i <= n; i++ ){
			if( str[i] == '(' ){
				s.push( i );
			}
			else{
				int idx = s.top();
				s.pop();
				d[idx] = i;
				d[i] = idx;
			}
		}
		int pos = k;
		char op;
		scanf("%s",opr);
		for( int i = 0; i < m; i++ ){
			op = opr[i];
			if( op == 'L' ){
				pos = l[pos];
			}
			if( op == 'R' ){
				pos = r[pos];
			}
			if( op == 'D' ){
				int nl,nr;
				if( str[pos] == '(' ){
					nl = l[pos];
					nr = r[d[pos]];
				}
				else{
					nl = l[d[pos]];
					nr = r[pos];
				}
				pos = nr;
				if( pos > n ){
					pos = l[pos];
				}
				r[nl] = nr;
				l[nr] = nl;
			}
		}
		for( int i = r[0]; i <= n; i = r[i] ){
			printf("%c",str[i]);
		}
		printf("\n");
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:66777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <string>
#include <string>
#include <stack>

using namespace std;

#define ldouble long double
#define ll long long
#define ull unsigned long long
#define mk make_pair
#define linf 2e16
#define inf 2e9
#define Size 500005
#define nl nullptr
#define eps 0.00000001
#define TL clock() * 1.0 / CLOCKS_PER_SEC

struct treap {
	treap *l, *r;
	ll x, y;
	treap(ll x) : x(x), l(nl), r(nl), y(rand()) {}
};

string st;
ll N, M, P;
map<ll, ll> Mp, In;

pair<treap*, treap*> split(treap *t, ll x) {
	if (t == nl)
		return mk(nl, nl);

	if (t->x < x) {
		auto h = split(t->r, x);
		t->r = h.first;
		return mk(t, h.second);
	}
	else {
		auto h = split(t->l, x);
		t->l = h.second;
		return mk(h.first, t);
	}
}

treap *merge(treap *a, treap *b) {
	if (a == nl)
		return b;
	if (b == nl)
		return a;

	if (a->y > b->y) {
		a->r = merge(a->r, b);
		return a;
	}
	else {
		b->l = merge(a, b->l);
		return b;
	}
}

void out(treap *t) {
	if (t == nl)
		return;
	out(t->l);

	cout << st[t->x];

	out(t->r);
}

ll right(treap *t) {
	if (t->r == nl)
		return t->x;
	return right(t->r);
}

ll left(treap *t) {
	if (t->l == nl)
		return t->x;
	return left(t->l);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);

	cin >> N >> M >> P;

	P--;

	treap *t = nl;

	cin >> st;

	ll bal = 0;
	for (int i = 0; i < N; i++) {
		t = merge(t, new treap(i));
		if (st[i] == '(') {
			bal++;
			In[bal] = i;
		}
		else {
			bal--;
			Mp[i] = In[bal + 1];
			Mp[In[bal + 1]] = i;

		}
	}
	Mp[0] = N - 1;
	Mp[N - 1] = 0;

	for (int i = 0; i < M; i++) {
		char a;
		cin >> a;
		if (a == 'R') {
			auto h = split(t, P + 1);
			P = left(h.second);
			t = merge(h.first, h.second);
		}
		else if (a == 'L') {
			auto h = split(t, P);
			P = right(h.first);
			t = merge(h.first, h.second);
		}
		else {
			auto h = split(t, min(P, Mp[P]));
			auto h2 = split(h.second, max(P, Mp[P]) + 1);

			if (h2.second == nl) {
				P = right(t);
			}
			else
				P = left(h2.second);

			t = merge(h.first, h2.second);
		}
	}

	out(t);

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:66777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <string>
#include <string>
#include <stack>

using namespace std;

#define ldouble long double
#define ll long long
#define ull unsigned long long
#define mk make_pair
#define linf 2e16
#define inf 2e9
#define Size 500005
#define nl nullptr
#define eps 0.00000001
#define TL clock() * 1.0 / CLOCKS_PER_SEC

struct treap {
	treap *l, *r;
	ll x, y;
	treap(ll x) : x(x), l(nl), r(nl), y(rand()) {}
};

string st;
ll N, M, P;
map<ll, ll> Mp, In;

pair<treap*, treap*> split(treap *t, ll x) {
	if (t == nl)
		return mk(nl, nl);

	if (t->x < x) {
		auto h = split(t->r, x);
		t->r = h.first;
		return mk(t, h.second);
	}
	else {
		auto h = split(t->l, x);
		t->l = h.second;
		return mk(h.first, t);
	}
}

treap *merge(treap *a, treap *b) {
	if (a == nl)
		return b;
	if (b == nl)
		return a;

	if (a->y > b->y) {
		a->r = merge(a->r, b);
		return a;
	}
	else {
		b->l = merge(a, b->l);
		return b;
	}
}

void out(treap *t) {
	if (t == nl)
		return;
	out(t->l);

	cout << st[t->x];

	out(t->r);
}

ll right(treap *t) {
	if (t->r == nl)
		return t->x;
	return right(t->r);
}

ll left(treap *t) {
	if (t->l == nl)
		return t->x;
	return left(t->l);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);

	cin >> N >> M >> P;

	P--;

	treap *t = nl;

	cin >> st;

	ll bal = 0;
	for (int i = 0; i < N; i++) {
		t = merge(t, new treap(i));
		if (st[i] == '(') {
			bal++;
			In[bal] = i;
		}
		else {
			bal--;
			Mp[i] = In[bal + 1];
			Mp[In[bal + 1]] = i;

		}
	}
	Mp[0] = N - 1;
	Mp[N - 1] = 0;

	for (int i = 0; i < M; i++) {
		char a;
		cin >> a;
		if (a == 'R') {
			auto h = split(t, P + 1);
			P = left(h.second);
			t = merge(h.first, h.second);
		}
		else if (a == 'L') {
			auto h = split(t, P);
			P = right(h.first);
			t = merge(h.first, h.second);
		}
		else {
			auto h = split(t, min(P, Mp[P]));
			auto h2 = split(h.second, max(P, Mp[P]) + 1);

			if (h2.second == nl)
				P = right(h.first);
			else
				P = left(h2.second);

			t = merge(h.first, h2.second);
		}
	}

	out(t);

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

//#pragma comment(linker, "/STACK:66777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <string>
#include <string>
#include <stack>

using namespace std;

#define ldouble long double
#define ll long long
#define ull unsigned long long
#define mk make_pair
#define linf 2e16
#define inf 2e9
#define Size 500005
#define nl nullptr
#define eps 0.00000001
#define TL clock() * 1.0 / CLOCKS_PER_SEC

struct treap {
	treap *l, *r;
	ll x, y;
	treap(ll x) : x(x), l(nl), r(nl), y(rand()) {}
};

string st;
ll N, M, P;
map<ll, ll> Mp, In;

pair<treap*, treap*> split(treap *t, ll x) {
	if (t == nl)
		return mk(nl, nl);

	if (t->x < x) {
		auto h = split(t->r, x);
		t->r = h.first;
		return mk(t, h.second);
	}
	else {
		auto h = split(t->l, x);
		t->l = h.second;
		return mk(h.first, t);
	}
}

treap *merge(treap *a, treap *b) {
	if (a == nl)
		return b;
	if (b == nl)
		return a;

	if (a->y > b->y) {
		a->r = merge(a->r, b);
		return a;
	}
	else {
		b->l = merge(a, b->l);
		return b;
	}
}

void out(treap *t) {
	if (t == nl)
		return;
	out(t->l);

	cout << st[t->x];

	out(t->r);
}

ll right(treap *t) {
	if (t->r == nl)
		return t->x;
	return right(t->r);
}

ll left(treap *t) {
	if (t->l == nl)
		return t->x;
	return left(t->l);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);

	cin >> N >> M >> P;

	P--;

	treap *t = nl;

	cin >> st;

	ll bal = 0;
	for (int i = 0; i < N; i++) {
		t = merge(t, new treap(i));
		if (st[i] == '(') {
			bal++;
			In[bal] = i;
		}
		else {
			bal--;
			Mp[i] = In[bal + 1];
			Mp[In[bal + 1]] = i;

		}
	}

	for (int i = 0; i < M; i++) {
		char a;
		cin >> a;
		if (a == 'R') {
			auto h = split(t, P + 1);
			P = left(h.second);
			t = merge(h.first, h.second);
		}
		else if (a == 'L') {
			auto h = split(t, P);
			P = right(h.first);
			t = merge(h.first, h.second);
		}
		else {
			auto h = split(t, min(P, Mp[P]));
			auto h2 = split(h.second, max(P, Mp[P]) + 1);

			if (h2.second == nl)
				P = right(h.first);
			else
				P = left(h2.second);

			t = merge(h.first, h2.second);
		}
	}

	out(t);

	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define vch vector<char>
#define loop(j,n) for(int i=j;i<n;i++)
using namespace std;
ll n, m, k;
vch x;
vch v;
ll solve(ll k)
{
	if (x[k] == '(')
	{
		ll tot=0;
		int r = k;
		loop(k, n + 1)
		{
			if (x[i] == ')')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + k, x.begin() + r+1);

		if (k == x.size())k--;
	}
	else
	{
		ll tot = 0;
		int r = k;
		for (int i = k; i > 0;i--)
		{
			if (x[i] == '(')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + r, x.begin() + k+1);
		k = r;
		if (k == x.size())k--;
	}
	return k;
}
int main()
{
	string h, d;
	cin >> n >> m >> k;
	cin >> h;
	cin >> d;
	x.resize(n + 2);
	v.resize(m + 2);
	loop(1, n + 1) { x[i] = h[i - 1]; }
	loop(1, m + 1) v[i]=d[i-1];
	loop(1, m + 1)
	{
		//cout << i << "   " << k << endl;
		if (v[i] == 'R')k++;
		else if (v[i] == 'L')k--;
		else k=solve(k);
	}
	for (int i = 1; i < x.size(); i++)
	{
		cout << x[i];
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define vch vector<char>
#define loop(j,n) for(int i=j;i<n;i++)
using namespace std;
ll n, m, k;
vch x;
vch v;
ll solve(ll k)
{
	if (x[k] == '(')
	{
		ll tot=0;
		int r = k;
		loop(k, n + 1)
		{
			if (x[i] == ')')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + k, x.begin() + r+1);

		if (k == x.size())k--;
	}
	else
	{
		ll tot = 0;
		int r = k;
		for (int i = k; i > 0;i--)
		{
			if (x[i] == '(')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + r, x.begin() + k+1);
		k = r;
		if (k == x.size())k--;
	}
	return k;
}
int main()
{
	string h, d;
	cin >> n >> m >> k;
	cin >> h;
	cin >> d;
	x.resize(n + 2);
	v.resize(m + 2);
	loop(1, n + 1) { x[i] = h[i - 1]; }
	loop(1, m + 1) v[i]=d[i-1];
	loop(1, m + 1)
	{
		//cout << i << "   " << k << endl;
		if (v[i] == 'R')k++;
		else if (v[i] == 'L')k--;
		else k=solve(k);
	}
	string t = "";
	for (int i = 1; i < x.size(); i++)
	{
		t += x[i];
	}
	cout << t;
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define vch vector<char>
#define loop(j,n) for(int i=j;i<n;i++)
using namespace std;
ll n, m, k;
vch x;
vch v;
ll solve(ll k)
{
	if (x[k] == '(')
	{
		ll tot=0;
		int r = k;
		loop(k, n + 1)
		{
			if (x[i] == ')')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + k, x.begin() + r+1);

		if (k == x.size())k--;
	}
	else
	{
		ll tot = 0;
		int r = k;
		for (int i = k; i > 0;i--)
		{
			if (x[i] == '(')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + r, x.begin() + k+1);
		k = r;
		if (k == x.size())k--;
	}
	return k;
}
int main()
{
	string h, d;
	cin >> n >> m >> k;
	cin >> h;
	cin >> d;
	x.resize(n + 2);
	v.resize(m + 2);
	loop(1, n + 1) { x[i] = h[i - 1]; }
	loop(1, m + 1) v[i]=d[i-1];
	loop(1, m + 1)
	{
		//cout << i << "   " << k << endl;
		if (v[i] == 'R')k++;
		else if (v[i] == 'L')k--;
		else k=solve(k);
	}
	for (int i = 1; i < x.size(); i++)
	{
		cout << x[i];
	}
	cout << endl;
	//system("pause");
	return 0;
}


#include <immintrin.h>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <cstdint>
#include <numeric>

void run(std::istream &in, std::ostream &out) {
	int n, m, p;
	in >> n >> m >> p;
	p--;
	std::string s;
	in >> s;
	std::vector<int> prev(n);
	std::iota(prev.begin(), prev.end(), -1);
	std::vector<int> next(n);
	std::iota(next.begin(), next.end(), 1);
	std::vector<int> other(n);
	std::vector<int> stack;
	for (int i = 0; i < n; i++) {
		if (s[i] == '(') {
			stack.push_back(i);
		}
		else {
			other[i] = stack.back();
			other[stack.back()] = i;
			stack.pop_back();
		}
	}
	std::string commands;
	in >> commands;
	for (size_t i = 0; i < commands.length(); i++) {
		switch (commands[i]) {
		case 'L':
			p = prev[p];
			break;
		case 'R':
			p = next[p];
			break;
		case 'D':
		{
					int otherp = other[p];
					if (otherp < p) {
						std::swap(p, otherp);
					}
					if (prev[p] >= 0) {
						next[prev[p]] = next[otherp];
					}
					if (next[otherp] < n) {
						prev[next[otherp]] = prev[p];
					}
					if (next[otherp] < n) {
						p = next[otherp];
					}
					else {
						p = prev[p];
					}
		}
		}
	}
	while (prev[p] >= 0) {
		p = prev[p];
	}
	std::string result(1, s[p]);
	while (next[p] < n) {
		p = next[p];
		result.append(1, s[p]);
	}
	out << result << std::endl;
}

int main() {
	std::cin.sync_with_stdio(false);
	std::cin.tie(nullptr);
	run(std::cin, std::cout);
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define vch vector<char>
#define loop(j,n) for(int i=j;i<n;i++)
using namespace std;
ll n, m, k;
vch x;
vch v;
ll solve(ll k)
{
	if (x[k] == '(')
	{
		ll tot=0;
		int r = k;
		loop(k, n + 1)
		{
			if (x[i] == ')')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + k, x.begin() + r+1);

		if (k == x.size())k--;
	}
	else
	{
		ll tot = 0;
		int r = k;
		for (int i = k; i > 0;i--)
		{
			if (x[i] == '(')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + r, x.begin() + k+1);
		k = r;
		if (k == x.size())k--;
	}
	return k;
}
int main()
{
	string h, d;
	cin >> n >> m >> k;
	cin >> h;
	cin >> d;
	x.resize(n + 2);
	v.resize(m + 2);
	loop(1, n + 1) { x[i] = h[i - 1]; }
	loop(1, m + 1) v[i]=d[i-1];
	loop(1, m + 1)
	{
		//cout << i << "   " << k << endl;
		if (v[i] == 'R')k++;
		else if (v[i] == 'L')k--;
		else k=solve(k);
		//cout << k << endl;
	}
	string t = "";
	for (int i = 1; i < x.size(); i++)
	{
		if (x[i] == '(' || x[i] == ')')
		{
			t += x[i];
		}
	}
	cout << t;
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define vch vector<char>
#define loop(j,n) for(int i=j;i<n;i++)
using namespace std;
ll n, m, k;
vch x;
vch v;
ll solve(ll k)
{
	if (x[k] == '(')
	{
		ll tot=0;
		int r = k;
		loop(k, n + 1)
		{
			if (x[i] == ')')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + k, x.begin() + r+1);

		if (k == x.size())k--;
	}
	else
	{
		ll tot = 0;
		int r = k;
		for (int i = k; i > 0;i--)
		{
			if (x[i] == '(')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + r, x.begin() + k+1);
		k = r;
		if (k == x.size())k--;
	}
	return k;
}
int main()
{
	string h, d;
	cin >> n >> m >> k;
	cin >> h;
	cin >> d;
	x.resize(n + 2);
	v.resize(m + 2);
	loop(1, n + 1) { x[i] = h[i - 1]; }
	loop(1, m + 1) v[i]=d[i-1];
	loop(1, m + 1)
	{
		//cout << i << "   " << k << endl;
		if (v[i] == 'R')k++;
		else if (v[i] == 'L')k--;
		else k=solve(k);
		//cout << k << endl;
	}
	string t = "";
	for (int i = 1; i < x.size()-1; i++)
	{
		t += x[i];
	}
	cout << t;
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define vch vector<char>
#define loop(j,n) for(int i=j;i<n;i++)
using namespace std;
ll n, m, k;
vch x;
vch v;
ll solve(ll k,int ss)
{
	//cout << ss << endl;
	if (x[k] == '(')
	{
		ll tot=0;
		int r = k;
		loop(k, n + 1)
		{
			if (x[i] == ')')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + k, x.begin() + r+1);
		ss -= ((r + 1) - k);
		if (k > ss)k--;
	}
	else
	{
		ll tot = 0;
		int r = k;
		for (int i = k; i > 0;i--)
		{
			if (x[i] == '(')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + r, x.begin() + k+1);
		ss -= ((k + 1) - r);
		k = r;
		if (k > ss)k--;
	}
	n = ss;
	return k;
}
int main()
{
	string h, d;
	cin >> n >> m >> k;
	cin >> h;
	cin >> d;
	x.resize(n + 2);
	v.resize(m + 2);
	loop(1, n + 1) { x[i] = h[i - 1]; }
	loop(1, m + 1) v[i]=d[i-1];
	loop(1, m + 1)
	{
		//cout << i << "   " << k << endl;
		if (v[i] == 'R')k++;
		else if (v[i] == 'L')k--;
		else k=solve(k,n);
		//cout << k << endl;
	}
	string t = "";
	for (int i = 1; i <= n; i++)
	{
		if (x[i] == '(' || x[i] == ')')
		{
			t += x[i];
		}
	}
	cout << t;
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define ll long long
#define vch vector<char>
#define loop(j,n) for(int i=j;i<n;i++)
using namespace std;
ll n, m, k;
vch x;
vch v;
ll solve(ll k)
{
	if (x[k] == '(')
	{
		ll tot=0;
		int r = k;
		loop(k, n + 1)
		{
			if (x[i] == ')')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + k, x.begin() + r+1);

		if (k == x.size())k--;
	}
	else
	{
		ll tot = 0;
		int r = k;
		for (int i = k; i > 0;i--)
		{
			if (x[i] == '(')tot--;
			else tot++;
			if (tot == 0){
				r = i; break;
			}
		}
		x.erase(x.begin() + r, x.begin() + k+1);
		k = r;
		if (k == x.size())k--;
	}
	return k;
}
int main()
{
	string h, d;
	cin >> n >> m >> k;
	cin >> h;
	cin >> d;
	x.resize(n + 2);
	v.resize(m + 2);
	loop(1, n + 1) { x[i] = h[i - 1]; }
	loop(1, m + 1) v[i]=d[i-1];
	loop(1, m + 1)
	{
		//cout << i << "   " << k << endl;
		if (v[i] == 'R')k++;
		else if (v[i] == 'L')k--;
		else k=solve(k);
	}
	string t = "";
	for (int i = 1; i < x.size(); i++)
	{
		t += x[i];
	}
	cout << t<<" ";
	//system("pause");
	return 0;
}


#include <iostream>
using namespace std;
#define N 520000
int n, m, p;
char str[N], op[N];
int leftIdx[N], rightIdx[N], match[N];
bool out[N];
int stack[N];
void solve()
{
	int i, j = 0, v;
	for (i = 0; i < n; i++) {
		leftIdx[i] = i - 1;
		rightIdx[i] = i + 1;
		out[i] = 1;
		if (str[i] == '(') {
			stack[j++] = i;
		} else {
			v = stack[--j];
			match[v] = i;
			match[i] = v;
		}
	}
	p--;
	for (i = 0; i < m; i++) {
		if (op[i] == 'L') {
			p = leftIdx[p];
		} else if (op[i] == 'R') {
			p = rightIdx[p];
		} else {
			v = match[p];
			if (v > p) {
				j = v;
				v = p;
				p = j;
			}
			if (leftIdx[v] >= 0) {
				rightIdx[leftIdx[v]] = rightIdx[p];
			}
			if (rightIdx[p] < n) {
				leftIdx[rightIdx[p]] = leftIdx[v];
			}
			out[p] = out[v] = 0;
			p = rightIdx[p] >= n ? leftIdx[v] : rightIdx[p];
		}
	}
	j = 0;
	for (i = 0; i < n;) {
		if (out[i] == 0 && str[i] == '(') {
			i = match[i] + 1;
		} else {
			printf("%c", str[i]);
			i++;
		}
	}
	printf("\n");
}
int main() {

	while (scanf("%d %d %d", &n, &m, &p) != EOF)
	{
		scanf(" %s %s", &str, &op);
		solve();
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <list>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

//#define _LOCAL_DEBUG_
#ifdef _LOCAL_DEBUG_
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

const int MAX = 5e5 + 100;
int n, q, p;
char s[MAX];
char op[MAX];

void clear() {
}

void solve() {
	scanf("%s", s);
	scanf("%s", op);
	list<pii> l;
	vi stack;
	for (int i = 0; i < n; i++) {
		if (s[i] == '(') {
			stack.push_back(i);
			l.push_back(pii(i, 0));
		}
		else {
			int idx = stack.back();
			stack.pop_back();
			l.push_back(pii(idx, 1));
		}
	}

	l.push_back(pii(-1, -1));
	l.push_front(pii(-1, -1));

	list<pii>::iterator it = l.begin();
	it++;
	for (int i = 0; i < p - 1; i++) it++;
	for (int iq = 0; iq < q; iq++) {
		if (op[iq] == 'L') it--;
		else if (op[iq] == 'R') it++;
		else {
			int idx = it->first, type = it->second;
			if (type == 0) {
				list<pii>::iterator to = it;
				while (to->first != idx || to->second != 1) to++;
				to++;
				l.erase(it, to);
				it = to;
				if (it->first == -1) it--;
			}
			else {
				list<pii>::iterator from = it;
				while (from->first != idx || from->second != 0) from--;
				it++;
				l.erase(from, it);
				if (it->first == -1) it--;
			}
		}
	}

	it = l.begin();
	it++;
	while (it->first != -1) {
		printf("%c", it->second ? ')' : '(');
		it++;
	}
	printf("\n");
}

int main() {
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%d%d%d", &n, &q, &p) == 3) {
		clear();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <limits>
#include <iomanip>
#include <ctime>
#include <map>
#include <queue>
#include <stack>

using namespace std;

long long mod = 1000000007;

int main()  {
	int n,m,p;
	cin >> n >> m >> p;
	string s; cin >> s;
	string com; cin >> com;

	vector<int> r(n);
	vector<int> l(n);
	vector<int> d(n);
	r[n-1] = -1;
	r[0] = 1;
	l[0] = -1;
	l[n-1] = n-2;
	for( int i = 1; i < n-1; i++ ) {
		r[i] = i+1;
		l[i] = i-1;
	}

	stack<int> st;
	for( int i = 0; i < n; i++ ) {
		if( s[i] == '(' ) {
			st.push(i);
		} else {
			int t = st.top();
			st.pop();
			d[t] = i;
			d[i] = t;
		}
	}
	int left = 0;
	p -=1;
	for( int i = 0; i < m; i++ ) {
		if( com[i] == 'R' ) {
			p = r[p];
			continue;
		}
		if( com[i] == 'L' ) {
			p = l[p];
			continue;
		}
		if( s[p] == '(' )
			p = d[p];
		if( r[p] != -1 ) {
			l[r[p]] = l[d[p]];
			if(l[d[p]] != -1 ) {
				r[l[d[p]]] = r[p];
			}
			p = r[p];
			if( l[p] == -1 )
				left = p;
		} else {
			r[l[d[p]]] = -1;
			p = l[d[p]];
		}
	}
	p = left;
	string ans;
	while( p != -1 ) {
		ans +=s[p];
		p = r[p];
	}
	cout << ans;
	return 0;
}


#include <stdio.h>
#include <list>
using namespace std;

const int MAX = 5e5 + 10;
int n, m, p, cnt;
char s[MAX], q[MAX];
list <char> li;
list <char>::iterator it;

int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d %d %d %s %s", &n, &m, &p, s + 1, q + 1);
    for (int i = 1; i <= n; ++i)
        li.push_back(s[i]);

    it = li.begin();
    for (int i = 2; i <= p; ++i)
        ++it;

    for (int i = 1; i <= m; ++i)
    if (q[i] == 'L')
        --it;
    else
    if (q[i] == 'R')
        ++it;
    else{
        cnt = 1;
        if (*it == '('){
            it = li.erase(it);
            do{
                cnt += (*it == '(' ? 1 : -1);
                it = li.erase(it);
            } while (cnt > 0);
        }
        else{
            it = li.erase(it);
            do{
                --it;
                cnt += (*it == ')' ? 1 : -1);
                it = li.erase(it);
            } while (cnt > 0);
        }
        if (it == li.end())
            --it;
    }

    for (it = li.begin(); it != li.end(); ++it)
        printf("%c", *it);

    return 0;
}


#include <stdio.h>
#include <list>
using namespace std;

const int MAX = 5e5 + 10;
int n, m, p, cnt;
char s[MAX], q[MAX];
list <char> li;
list <char>::iterator it;

int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d %d %d %s %s", &n, &m, &p, s + 1, q + 1);
    for (int i = 1; i <= n; ++i)
        li.push_back(s[i]);

    it = li.begin();
    for (int i = 2; i <= p; ++i)
        ++it;

    for (int i = 1; i <= m; ++i)
    if (q[i] == 'L')
        --it;
    else
    if (q[i] == 'R')
        ++it;
    else
    if (*it == '('){
        cnt = 1;
        it = li.erase(it);
        do{
            cnt += (*it == '(' ? 1 : -1);
            it = li.erase(it);
        } while (cnt > 0);
        if (it == li.end())
            --it;
    }
    else{
        cnt = 1;
        it = li.erase(it);
        do{
            --it;
            cnt += (*it == ')' ? 1 : -1);
            it = li.erase(it);
        } while (cnt > 0);
    }

    for (list <char>::iterator it = li.begin(); it != li.end(); ++it)
        printf("%c", *it);

    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>

#pragma warning(disable:4996)

int idxTree[1 << 20], size;

void Init(int n)
{
	for (size = 1; size < n; size *= 2);
	for (int i = size; i < size + n; ++i)
		idxTree[i] = 1;
	for (int i = size + n; i < 2 * size; ++i)
		idxTree[i] = 0;

	for (int i = size - 1; i > 0; --i)
		idxTree[i] = idxTree[2 * i] + idxTree[2 * i + 1];
}

int GetPos(int sum)
{
	if (idxTree[1] < sum)
		sum = idxTree[1];

	if (sum < 0)
		sum = 0;

	int idx = 1;
	while (idx < size)
	{
		if (idxTree[2 * idx] < sum)
		{
			sum -= idxTree[2 * idx];
			idx = 2 * idx + 1;
		}
		else
		{
			idx = 2 * idx;
		}
	}

	return idx - size;
}

int GetSum(int s)
{
	int sum = idxTree[size + s];

	for (int pos = size + s; pos > 1; pos /= 2)
	{
		if (pos % 2 == 1)
		{
			sum += idxTree[pos - 1];
		}
	}

	return sum;
}

void NodeUpdate(int s)
{
	idxTree[s] = 0;
	for (int tmp = s / 2; tmp > 0; tmp /= 2)
	{
		idxTree[tmp] = idxTree[2 * tmp] + idxTree[2 * tmp + 1];
	}
}

void Update(int s, int e)
{
	int left = size + s, right = size + e;
	while (left < right)
	{
		if (left % 2 == 1)
		{
			NodeUpdate(left);
			left++;
		}
		if (right % 2 == 0)
		{
			NodeUpdate(right);
			right--;
		}

		left /= 2;
		right /= 2;
	}

	if (left == right)
	{
		NodeUpdate(left);
	}
}

int main()
{
	int n, m, p;
	std::string bracket, query;

	std::cin >> n >> m >> p;
	std::cin >> bracket;
	std::cin >> query;

	int cnt = p;
	p--;

	// tree init
	Init(n);

	std::vector<int> pair(n);
	std::vector<int> stack;
	for (int i = 0; i < n; ++i)
	{
		if (bracket[i] == '(')
		{
			stack.push_back(i);
		}
		else
		{
			int j = stack.back();
			stack.pop_back();

			pair[i] = j;
			pair[j] = i;
		}
	}

	for (int i = 0; i < m; ++i)
	{
		switch (query[i])
		{
		case 'R':
		{
			p = GetPos(cnt+1);
			cnt = GetSum(p);
			break;
		}
		case 'L':
		{
			p = GetPos(cnt-1);
			cnt = GetSum(p);
			break;
		}
		case 'D':
		{
			int q = pair[p];
			int st = std::min(p, q);
			int ed = std::max(p, q);

			// 왼쪽 포지션으로 일단 옮기자.
			cnt = GetSum(st);
			p = st;

			Update(st, ed);

			p = GetPos(cnt);
			cnt = GetSum(p);
			break;
		}
		}
	}

	int remain = idxTree[1];
	std::string ans;

	for (int i = 1; i <= remain; ++i)
	{
		p = GetPos(i);

		ans += bracket[p];
	}
	std::cout << ans;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>

int main()
{
	int n, m, p;
	std::cin >> n >> m >> p;

	std::string bracket, query;
	std::cin >> bracket;
	std::cin >> query;

	std::vector<int> pair(n);
	std::vector<int> stack;
	for (int i = 0; i < n; ++i)
	{
		if (bracket[i] == '(')
		{
			stack.push_back(i);
		}
		else
		{
			int j = stack.back();
			stack.pop_back();

			pair[i] = j;
			pair[j] = i;
		}
	}

	std::list< std::pair<int, char> > linkedList;
	for (int i = 0; i < n; ++i)
	{
		linkedList.push_back(std::make_pair(i, bracket[i]));
	}

	auto iter = linkedList.begin();
	for (int i = 1; i < p; ++i)
	{
		iter++;
	}

	for (int i = 0; i < m; ++i)
	{
		switch (query[i])
		{
		case 'R':
		{
			auto simul = iter;
			simul++;
			if (simul != linkedList.end())
			{
				iter = simul;
				p = iter->first;
			}
			break;
		}
		case 'L':
		{
			if (iter != linkedList.begin())
			{
				iter--;
				p = iter->first;
			}
			break;
		}
		case 'D':
		{
			int q = pair[p];
			if (p < q)
			{
				while (true)
				{
					int tmp = iter->first;
					auto ptr = iter;
					iter++;

					linkedList.erase(ptr);

					if (tmp == q)
					{
						break;
					}
				}

				if (iter == linkedList.end())
				{
					iter--;
				}
			}
			else
			{
				bool IsBegin = false;

				while (true)
				{
					int tmp = iter->first;
					auto ptr = iter;

					if (iter != linkedList.begin())
					{
						iter--;
					}
					else
					{
						IsBegin = true;
					}

					linkedList.erase(ptr);

					if (IsBegin == true)
					{
						iter = linkedList.begin();
					}

					if (tmp == q)
					{
						break;
					}
				}

				if (IsBegin == false)
				{
					iter++;
				}
			}
			p = iter->first;
			break;
		}
		}
	}

	std::string ans;
	for (auto& itr : linkedList)
	{
		ans += itr.second;
	}

	std::cout << ans;
}


#pragma warning( disable : 4996)
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:666000000")

#define bublic public

#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <time.h>
#include <vector>
#include <stack>

#define nextLine() {for(int c=getchar(); c!='\n' && c!=EOF; c=getchar());}
#define sqr(a) ((a)*(a))
#define has(mask,i) (((mask) & (1<<(i))) == 0 ? false : true)
#define set_true(mask, i) (mask|(1<<(i)))
#define set_false(mask, i) (~((~mask)|(1<<(i))))

#define Equal(a, b) (fabsl(a-b) < 1e-9)
#define Less(a, b) (a < b && !Equal(a, b))
#define Greater(a, b) (a > b && !Equal(a, b))

using namespace std;

#ifdef SCHULLZ
#define TASK "file"
#define eprintf(...) fprintf(stdout, __VA_ARGS__)
#define parr(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";puts("");}puts("");
#define log(x) cout << #x << " = " << x << endl
#else
#define TASK "file"
#define eprintf(...)
#define parr(a,n,m)
#define log(x)
#endif

#define pb(_o_) push_back(_o_)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double ldb;

typedef pair<int,int> pii;
typedef pair<pii,int> tiii;
typedef pair<pii,pii> fiiii;
#define aaa first.first
#define bbb first.second
#define ccc second.first
#define ddd second.second
#define mp(x, y) make_pair(x, y)
#define mpp(x, y, z) make_pair(mp(x, y), z)
#define mppp(x, y, z, a) make_pair(mp(x, y), mp(z, a))

#define sci(a) (1 == scanf("%d", &a))
#define scii(a,b) (2 == scanf("%d%d", &a, &b))
#define sciii(a,b,c) (3 == scanf("%d%d%d", &a, &b, &c))
#define sciiii(a,b,c,d) (4 == scanf("%d%d%d%d", &a, &b, &c, &d))
#define sciiiii(a,b,c,d,e) (5 == scanf("%d%d%d%d%d", &a, &b, &c, &d, &e))

#define scin(a) (1 == scanf("%d\n", &a))
#define sciin(a,b) (2 == scanf("%d%d\n", &a, &b))
#define sciiin(a,b,c) (3 == scanf("%d%d%d\n", &a, &b, &c))
#define sciiiin(a,b,c,d) (4 == scanf("%d%d%d%d\n", &a, &b, &c, &d))
#define sciiiiin(a,b,c,d,e) (5 == scanf("%d%d%d%d%d\n", &a, &b, &c, &d, &e))

#define FORN(i,n) for(int i = 0; i < (int)(n); i++)
#define FORR(i,n) for(int i = n - 1; i >= 0; i--)
#define FORS(it,a) for(auto it = a.begin(); it != a.end(); it++)
#define fill(a,v) memset(a,v,sizeof(a))

typedef vector<int> vi;
typedef vector<vi> vvi;

#ifdef SCHULLZ
typedef vector<int> vc;
typedef vector<vc> vvc;
#else
typedef vector<char> vc;
typedef vector<char> vvc;
#endif

const int INF = (1 << 30) - 1;
const ldb EPS = 1e-9;

void ML(const bool v)
{
	if (v)
		return;
	int *ass;
	for (;;)
	{
		ass = new int[2500000];
		for (int i = 0; i < 2500000; i++)
			ass[i] = rand();
	}
}

void TL(const bool v)
{
	if (v)
		return;
	for (;;)
		cout << rand() % (rand() % 1000 + 1) << endl;
}

void PE(const bool v)
{
	if (v)
		return;
	for (int i = 0; i < 10000; i++)
		printf("%c", rand() % 256);
	exit(0);
}

	char ord[500500];
int n, m, p;
list<char> a;

bool LoAd()
{
	if (!sciiin(n, m, p))
		return false;
	a.clear();
	scanf("%s", ord);
	a.push_back('-');
	for (int i = 0; i < n; i++)
		a.push_back(ord[i]);
	a.push_back('-');
	scanf("%s", ord);
	return true;
}

void SoLvE()
{
	list<char>::iterator cur = a.begin();
	for (int i = 0; i < p; i++)
		cur++;
	FORN(iii, m)
	{
		switch(ord[iii])
		{
		case 'R':
			cur++;
			break;
		case 'L':
			cur--;
			break;
		case 'D':
			if ('(' == *cur)
			{
				stack<char> st;
				st.push(*cur);
				auto doom = cur;
				while (!st.empty())
				{
					cur++;
					a.erase(doom);
					//if (!st.empty() && st.top() == '(' && *cur == ')')
					if (st.top() == '(' && *cur == ')')
						st.pop();
					else
						st.push(*cur);
					doom = cur;
				}
				cur++;
				a.erase(doom);
				if ('-' == *cur)
					cur--;
			}
			else
			{
				stack<char> st;
				st.push(*cur);
				auto doom = cur;
				while (!st.empty())
				{
					cur--;
					a.erase(doom);
					//if (!st.empty() && st.top() == '(' && *cur == ')')
					if (st.top() == ')' && *cur == '(')
						st.pop();
					else
						st.push(*cur);
					doom = cur;
				}
				cur--;
				a.erase(doom);
				cur++;
				if ('-' == *cur)
					cur--;
			}
			break;
		default:
			exit(1);
		}
	}
	a.pop_back();
	a.pop_front();
	FORS(it, a)
		printf("%c", *it);
	puts("");
}

int main()
{
	srand( (int) time(NULL));
#ifdef SCHULLZ
    freopen(TASK".in","r",stdin);   freopen(TASK".out","w",stdout);
	for (int i = 0; LoAd(); i++)
		SoLvE();
#else
	LoAd();
	SoLvE();
#endif
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <time.h>
#include <random>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#define rt return
#define rt0 return 0
#define rt1 return 1
#define mp make_pair
#define cen cout << "\n"
#define endl "\n"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1000000009;

int n, m, p;

struct st{
	int v, l, r, p;
}a[500100];
char s[500100];
vector<int> v;
int main(){
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	cin >> n >> m >> p;
	char c;
	a[0].r = 1;
	for (int i = 1; i <= n; ++i){
		cin >> c;
		a[i].v = (c == '(' ? 1 : 0);
		a[i].l = i - 1;
		a[i].r = i + 1;
		a[i].p = -1;
	}
	a[n + 1].l = n;
	for (int i = 1; i <= n; ++i){
		if (a[i].v)
			v.push_back(i);
		else if (!v.empty()){
			a[i].p = v.back();
			a[v.back()].p = i;
			v.pop_back();
		}
	}
	cin >> s;
	for (int i = 0; i < m; ++i){
		c = s[i];
		if (c == 'R')
			p = a[p].r;
		if (c == 'L')
			p = a[p].l;
		if (c == 'D'){
			if (a[p].p > p){
				a[a[p].l].r = a[a[p].p].r;
				a[a[a[p].p].r].l = a[p].l;
				if (a[a[p].p].r == n + 1)
					p = a[p].l;
				else
					p = a[a[p].p].r;
			}
			else{
				int t = p;
				p = a[p].p;
				a[a[p].l].r = a[a[p].p].r;
				a[a[a[p].p].r].l = a[p].l;
				if (a[a[p].p].r == n + 1)
					p = a[p].l;
				else
					p = a[a[p].p].r;
			}
		}
	}
	int u = a[0].r;
	while (u != n + 1){
		cout << (a[u].v ? '(' : ')');
		u = a[u].r;
	}

	return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cassert>
#include <queue>
#include <list>
#include <vector>
#include <stack>
#include <utility>
#include <malloc.h>
#include <cstdint>
#include <functional>

#define CLASS_TO_STRING(x) (#x)

template<class T>
struct ptr_min
{
	bool operator()(T* a,T* b) { return *a < *b; }
};

template<class T>
struct ptr_max
{
	bool operator()( T* a,T* b) { return *a > *b; }
};

const unsigned size = 5e5+1;

unsigned len, operations, pos;
char bracket[size], command[size],curr;

unsigned i, ii;
std::stack<char> left, right;

int main() {
	std::cin >> len >> operations >> pos >> bracket >> command;
	--pos;

	while(i < pos) {
		left.push(bracket[i++]);
	}
	curr = bracket[i];

	bracket[i] = '\0';
	i = len;
	while (bracket[--i]) {
		right.push(bracket[i]);
	}

	const char *p = command;

	while(*p) {

		if (*p == 'L') {
			right.push(curr);
			curr = left.top();
			left.pop();
		}
		else if (*p == 'R') {
			left.push(curr);
			curr = right.top();
			right.pop();
		}
		else {

			std::stack<char> trash;
			trash.push(curr);

			if (curr == '(') {
				while (trash.size()) {

					if (right.top() != trash.top()) {
						trash.pop();
					}
					else {
						trash.push(right.top());
					}

					right.pop();
				}
			}
			else {
				while (trash.size()) {

					if (left.top() != trash.top()) {
						trash.pop();
					}
					else {
						trash.push(left.top());
					}

					left.pop();
				}
			}

			if (right.size()) {
				curr = right.top();
				right.pop();
			}
			else {
				curr = left.top();
				left.pop();
			}
		}

		++p;
	}

	len=pos = left.size();
	while (pos--) {
		bracket[pos] = left.top();
		left.pop();
	}

	pos = len;
	bracket[pos++] = curr;
	while (right.size()) {
		bracket[pos++] = right.top();
		right.pop();
	}
	bracket[pos] = '\0';

	std::cout << bracket;

	return 0;
}


#pragma comment(linker,"/STACK:64000000")
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define mp make_pair
#define pb push_back
#define eps (double)(1e-9)
#define MOD (ll)(1e9 + 7)

const int maxlen = 5e5+10;
#define PI 3.14159265358979323846

void operator delete(void *){}
int par[maxlen];
int st[maxlen];
char s[maxlen];
char op[maxlen];
set<pii> S;
int nxt[maxlen];
int prv[maxlen];
int main()
{
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n,m,p;
	int i;
	int in_st = 0;
	scanf("%d%d%d\n",&n,&m,&p);
	scanf("%s",s);
	for(i=1;i<=n;++i)
	{
		if(i!=n)
			nxt[i] = i + 1;
		if(i!=1)
			prv[i] = i - 1;
	}
	prv[1] = 0;
	nxt[n] = n+1;
	nxt[0] = 1;
	prv[n+1] = n;
	for(i=0;i<n;++i)
	{
		if(s[i] == '(')
			st[in_st++] = i + 1;
		else
		{
			int v = st[--in_st];
			par[v] = i + 1;
			par[i+1] = v;
		}
	}
	scanf("%s",op);
	S.insert(mp(1,n));
	S.insert(mp(n+1,n+1));
	int x,y,xx,yy;
	for(i=0;i<m;++i)
	{
		if(op[i] == 'R')
			p = nxt[p];
		else if(op[i] == 'L')
			p = prv[p];
		else
		{
			x = par[p];
			y = p;
			if(x>y)
				swap(x,y);
			xx = prv[x];
			yy = nxt[y];
			nxt[xx] = yy;
			prv[yy] = xx;
			if(yy == -1)
				p = xx;
			else
				p = yy;
		}
	}
	i = 0;
	int v;
	while(nxt[i] != n+1)
	{
		v = nxt[i];
		printf("%c",s[v-1]);
		i = v;
	}
	return 0;
}


#pragma comment(linker,"/STACK:64000000")
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define mp make_pair
#define pb push_back
#define eps (double)(1e-9)
#define MOD (ll)(1e9 + 7)

const int maxlen = 5e5+10;
#define PI 3.14159265358979323846

void operator delete(void *){}
int par[maxlen];
int st[maxlen];
char s[maxlen];
char op[maxlen];
int nxt[maxlen];
int prv[maxlen];
int main()
{
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n,m,p;
	int i;
	int in_st = 0;
	int v;
	int x,y,xx,yy;
	scanf("%d%d%d\n",&n,&m,&p);
	scanf("%s",s);
	scanf("%s",op);
	for(i=1;i<=n;++i)
	{
		nxt[i] = i + 1;
		prv[i] = i - 1;
	}
	nxt[0] = 1;
	prv[n+1] = n;
	for(i=0;i<n;++i)
	{
		if(s[i] == '(')
			st[in_st++] = i + 1;
		else
		{
			v = st[--in_st];
			par[v] = i + 1;
			par[i+1] = v;
		}
	}
	for(i=0;i<m;++i)
	{
		if(op[i] == 'R')
			p = nxt[p];
		else if(op[i] == 'L')
			p = prv[p];
		else
		{
			x = par[p];
			y = p;
			if(x>y)
				swap(x,y);
			xx = prv[x];
			yy = nxt[y];
			nxt[xx] = yy;
			prv[yy] = xx;
			if(yy == n+1)
				p = xx;
			else
				p = yy;
		}
	}
	i = 0;
	while(nxt[i] != n+1)
	{
		v = nxt[i];
		printf("%c",s[v-1]);
		i = v;
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include <bitset>
#include <iomanip>
#include <map>
#include <string.h>
#include <stack>
#include <algorithm>

#include <unordered_map>
#include <unordered_set>

using namespace std;

vector<pair<int , int>> pairs;
char input[500010];
char operation[500010];
int l[500010] , r[500010];		// 左边和右边的下一个位置
int match_index[500010];		// 匹配的位置

void get_match_indexs(int n)
{
	stack<int> s;
	for (int i = 0;i < n;i ++)
	{
		if (input[i] == '(')
			s.push(i);
		// 如果是右括号
		else
		{
			int pos1 = s.top();
			s.pop();
			int pos2 = i;
			// 获得match index
			match_index[pos1] = pos2;
			match_index[pos2] = pos1;
		}
	}
}

int main()
{
	int i , j , n , m , p;
	while (scanf("%d%d%d" , &n , &m , &p) != EOF)
	{
		pairs.clear();
		memset(l , - 1 , sizeof(l));
		memset(r , - 1 , sizeof(r));
		scanf("%s%s" , input , operation);
		// l , r为左边和右边的坐标
		get_match_indexs(n);
		for (i = 0;i < n;i ++)
		{
			if (i + 1 < n)
				r[i] = i + 1;
			if (i - 1 >= 0)
				l[i] = i - 1;
		}
		// 需要从0开始
		p --;
		for (i = 0;i < m;i ++)
		{
			// 左右移动
			if (operation[i] == 'R')
			{
				int next_position = r[p];
				if (next_position >= 0)
					p = next_position;
			}
			else if (operation[i] == 'L')
			{
				int next_position = l[p];
				if (next_position >= 0)
					p = next_position;
			}
			// 如果是删除
			else
			{
				int match_position = match_index[p];
				// 如果是往后面移动
				// p match_position
				if (p <= match_position)
				{
					r[p] = - 1;
					// 如果右边没有了
					if (r[match_position] < 0)
					{
						p = l[p];
						// 右边不能移动了
						r[p] = - 1;
					}
					else
					{
						int next_position = r[match_position];
						if (l[p] >= 0)
							r[l[p]] = r[match_position];
						l[r[match_position]] = l[p];
						p = next_position;
					}
				}
				// 如果是往前面移动
				// match_position , p
				else
				{
					r[match_position] = - 1;
					if (r[p] >= 0)
					{
						int next_position = r[p];
						if (l[match_position] >= 0)
							r[l[match_position]] = r[p];
						l[r[p]] = l[match_position];
						p = next_position;
					}
					else
					{
						p = l[match_position];
						r[p] = - 1;
					}
				}
			}
		}
		int current = 0;
		while (current < n)
		{
			// 如果右边没有了，说明到match的所有都被删掉了
			if (r[current] < 0)
				current = match_index[current] + 1;
			else
			{
				// 如果存在r[current]
				int pos1 = current , pos2 = r[current];
				pairs.push_back(make_pair<int , int>(pos1 , pos2));
				current = pos2 + 1;
			}
		}
		// 所有的pair都是有效的
		for (i = 0;i < pairs.size();i ++)
		{
			for (j = pairs[i].first;j <= pairs[i].second;j ++)
				printf("%c" , input[j]);
		}
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include <bitset>
#include <iomanip>
#include <map>
#include <string.h>
#include <stack>
#include <algorithm>

#include <unordered_map>
#include <unordered_set>

using namespace std;

bool isEnd[500010];
char input[500010];
char operation[500010];
int l[500010] , r[500010];		// 左边和右边的下一个位置
int match_index[500010];		// 匹配的位置

void get_match_indexs(int n)
{
	stack<int> s;
	for (int i = 0;i < n;i ++)
	{
		if (input[i] == '(')
			s.push(i);
		// 如果是右括号
		else
		{
			int pos1 = s.top();
			s.pop();
			int pos2 = i;
			// 获得match index
			match_index[pos1] = pos2;
			match_index[pos2] = pos1;
		}
	}
}

int main()
{
	int i , j , n , m , p;
	while (scanf("%d%d%d" , &n , &m , &p) != EOF)
	{
		memset(isEnd , 0 , sizeof(isEnd));
		memset(l , - 1 , sizeof(l));
		memset(r , - 1 , sizeof(r));
		scanf("%s%s" , input , operation);
		// l , r为左边和右边的坐标
		get_match_indexs(n);
		for (i = 0;i < n;i ++)
		{
			if (i + 1 < n)
				r[i] = i + 1;
			if (i - 1 >= 0)
				l[i] = i - 1;
		}
		// 需要从0开始
		p --;
		for (i = 0;i < m;i ++)
		{
			// 左右移动
			if (operation[i] == 'R')
			{
				int next_position = r[p];
				if (next_position >= 0)
					p = next_position;
			}
			else if (operation[i] == 'L')
			{
				int next_position = l[p];
				if (next_position >= 0)
					p = next_position;
			}
			// 如果是删除
			else
			{
				int match_position = match_index[p];
				// 如果是往后面移动
				// p match_position
				if (p <= match_position)
				{
					r[p] = - 1;
					// 如果右边没有了
					if (r[match_position] < 0)
					{
						p = l[p];
						// 右边不能移动了
						r[p] = - 1;
						isEnd[p] = true;
					}
					else
					{
						int next_position = r[match_position];
						if (l[p] >= 0)
							r[l[p]] = r[match_position];
						l[r[match_position]] = l[p];
						p = next_position;
					}
				}
				// 如果是往前面移动
				// match_position , p
				else
				{
					r[match_position] = - 1;
					if (r[p] >= 0)
					{
						int next_position = r[p];
						if (l[match_position] >= 0)
							r[l[match_position]] = r[p];
						l[r[p]] = l[match_position];
						p = next_position;
					}
					else
					{
						p = l[match_position];
						r[p] = - 1;
					}
				}
			}
		}

		bool flag = false;
		int current = 0;
		while (current < n && current >= 0)
		{
			// 如果右边没有了，说明到match的所有都被删掉了
			if (r[current] < 0)
			{
				if (flag)
					printf("%c" , input[current]);

				flag = false;
				// 如果可以往后找
				if (current < match_index[current])
					current = match_index[current] + 1;
				else
					break;
			}
			else
			{
				flag = true;
				printf("%c" , input[current]);
				current = r[current];
			}
		}
		printf("\n");
	}
	return 0;
}


#define _CRT_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <vector>
#include <map>
#include<set>
#include <string>
#include<cstdlib>
#include <queue>
#include<iomanip>

using namespace std;

//#define int long long
#define fi(i, a, b) for(int i = (a); (i) < (b); (i)++)

const int N = 500005;

struct node{ int l, r; int num; int parent; int parentindex; vector<int> to; set<int> allowed; bool deleted; };
node a[N];
int n, m, p;
char s[N], c[N];
int cnt=1;

pair<int, int> goleft(int p){
	int parent = a[p].parent;
	set<int> :: iterator it = a[parent].allowed.find(a[p].parentindex);
	if (it == a[parent].allowed.begin()){
		return make_pair(parent, a[parent].l);
	}
	else{
		int e = a[parent].to[(*(--it))];
		return make_pair(e, a[e].r);
	}

}

pair<int,int> goright(int p){
	int parent = a[p].parent;
	int need = a[p].parentindex;
	set<int>::iterator it = a[parent].allowed.upper_bound(need);
	if (it == a[parent].allowed.end()){

		return make_pair(parent, a[parent].r);
	}
	else{
		return make_pair(a[parent].to[(*it)], a[a[parent].to[(*it)]].l);
	}
}

vector<char> ans;
void go(int p){
	for (set<int> ::iterator it = a[p].allowed.begin(); it != a[p].allowed.end(); ++it){
		ans.push_back('(');
		go(a[p].to[(*it)]);
		ans.push_back(')');
	}
}

void main()
{
#if defined(DEBUG) || defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d%d", &n, &m, &p); p--;
	scanf("%s%s", &s, &c);
  int cur = 0;
  int first;
  fi(i, 0, n){
	  if (s[i] == '('){
		  a[cur].to.push_back(cnt);
		  a[cur].allowed.insert(a[cur].to.size() - 1);
		  a[cnt].num = cnt;
		  a[cnt].parent = cur;
		  a[cnt].parentindex = a[cur].to.size() - 1;
		  a[cnt].l = i;
		  cur = cnt;
		  if (i == p)
			  first = cur;
		  cnt++;

	  }
	  else{
		  a[cur].r = i;
		  if (i == p)
			  first = cur;
		  cur = a[cur].parent;
	  }
  }

   cur = first;
  int pos = p;
  fi(i, 0, m){
	  if (c[i] == 'L'){
		  if (pos == a[cur].l){
			  pair<int, int> q = goleft(cur);
				  cur = q.first; pos = q.second;
		  }
		  else{
			  if (a[cur].allowed.size() == 0){
				  pos = a[cur].l;
			  }
			  else{
				  cur = a[cur].to[*(a[cur].allowed.rbegin())  ];
				  pos = a[cur].r;
			  }
		  }
	  }
	  else if (c[i] == 'R'){
		  if (pos == a[cur].r){
			  pair<int, int> q = goright(cur);
			  cur = q.first;
			  pos = q.second;

		  }
		  else{
			  if (a[cur].allowed.size() == 0){
				  pos = a[cur].r
					  ;
			  }
			  else{
				  cur = a[cur].to[*(a[cur].allowed.begin())];
				  pos = a[cur].l;
			  }
		  }
	  }
	  else{
		  a[cur].deleted = true;
		  int par = a[cur].parent;
		  pair<int, int> q = goright(cur);
		  if (q.first == 0)
			  q = goleft(cur);
		  a[par].allowed.erase(a[cur].parentindex);
		  cur = q.first; pos = q.second;
		  //0
	  }
  }

  go(0);
  fi(i, 0, ans.size()){
	  printf("%c", ans[i]);
  }

}