// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <algorithm>

#include <map>

using namespace std;

int n;

int A, B, C;

struct Coordinates

{

    int map[40000];

    bool rever;

    Coordinates()

    {

        for (int i = 0; i < 40000; ++ i)

            map[i] = i;

        rever = false;

    }

    void reverse()

    {

        rever = !rever;

    } 

    int &operator [] (int a)

    {

        if (rever == true)

            return map[n - 1 - a];

        else

            return map[a];

    }

}X, Y;

Coordinates &x = X, &y = Y;

map <pair <int, int>, int > num;

bool flag = false;

pair <int, int> getCoorddinates(int a, int b)

{

    if (flag == false)

        return make_pair(x[a], y[b]);

    else

        return make_pair(y[b], x[a]);

}

int calc(pair <int, int> a)

{

    return ((long long) a.first * A + A + (long long) a.second * B + B) % C;

}

int &getNum(pair <int, int> a)

{

    if (num.find(a) != num.end())

        return num[a];

    else

        return num[a] = calc(a);

}

int getNum2(pair <int, int> a)

{

    if (num.find(a) != num.end())

        return num[a];

    else

        return calc(a);

}

void reflectHorizontal()

{

    x.reverse();

}

void reflectVertical()

{

    y.reverse();

}

void rotateLeft()

{

    flag = !flag;

    swap(x, y);

    x.reverse();

}

void rotateRight()

{

    flag = !flag;

    swap(x, y);

    y.reverse();

}

void swapColumn(int a, int b)

{

    swap(y[a], y[b]);

}

void swapRow(int a, int b)

{

    swap(x[a], x[b]);

}

char s[3];

int main()

{

    int q;

    scanf("%d%d", &n, &q);

    scanf("%d%d%d", &A, &B, &C);

    int D, E, F, G;

    scanf("%d%d%d%d", &D, &E, &F, &G);

    while (q --)

    {

        scanf("%s", s);

        if (strcmp(s, "WR") == 0)

        {

            int r, c, v;

            scanf("%d%d%d", &r, &c, &v);

            -- r;

            -- c;

            getNum(getCoorddinates(r, c)) = v;

        }

        else if (strcmp(s, "CP") == 0)

        {

            int r1, c1, r2, c2;

            scanf("%d%d%d%d", &r1, &c1, &r2, &c2);

            -- r1;

            -- c1;

            -- r2;

            -- c2;

            getNum(getCoorddinates(r2, c2)) = getNum(getCoorddinates(r1, c1));

        }

        else if (strcmp(s, "SR") == 0)

        {

            int r1, r2;

            scanf("%d%d", &r1, &r2);

            -- r1;

            -- r2;

            swapRow(r1, r2);

        }

        else if (strcmp(s, "SC") == 0)

        {

            int c1, c2;

            scanf("%d%d", &c1, &c2);

            -- c1;

            -- c2;

            swapColumn(c1, c2);

        }

        else if (strcmp(s, "RL") == 0)

            rotateLeft();

        else if (strcmp(s, "RR") == 0)

            rotateRight();

        else if (strcmp(s, "RH") == 0)

            reflectHorizontal();

        else 

            reflectVertical();

//        for (int r = 0; r < n; ++ r, puts(""))

//            for (int c = 0; c < n; ++ c)

//                printf("%d ", getNum2(getCoorddinates(r, c)));

    } 

    int h = 314159265;

    for (int r = D - 1; r < E; ++ r)

        for (int c = F - 1; c < G; ++ c)

            h = ((long long) h * 31 + getNum2(getCoorddinates(r, c))) % 1000000007;

    printf("%d\n", h);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.402231346133115x):
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <map>



using namespace std;



const int maxn=4e4+5;



bool RH,RV,R;

int row[maxn],colum[maxn];

int A,B,C,D,E,F,G,n,q;



struct HashMap

{

    int mod;

    int begin[100007],next[maxn],val[maxn],key[maxn];

    int s,i,num;

    void ini()

    {

        mod=100007;

        memset(begin,-1,sizeof(begin));

        num=0;

    }

    int back(int x,int y)

    {

        s=x*n+y;

        for(i=begin[s%mod];i!=-1;i=next[i])

            if(key[i]==s)return val[i];

        return (A*(long long)x+B*(long long)y)%C;

    }

    void change(int x,int y,int k)

    {

        s=x*n+y;

        for(i=begin[s%mod];i!=-1;i=next[i])

            if(key[i]==s)

            {

                val[i]=k;

                return;

            }

        key[num]=s;

        val[num]=k;

        s=s%mod;

        next[num]=begin[s];

        begin[s]=num++;

    }

}S;



void change(int &r,int &c)

{

    if(R)swap(r,c);

    if(RH)r=row[n+1-r];

    else r=row[r];

    if(RV)c=colum[n+1-c];

    else c=colum[c];

}



const int mod=1e9+7;



int r1,r2,c1,c2,r,c,v;

char s[10];



int main()

{

    scanf("%d%d",&n,&q);

    scanf("%d%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F,&G);

    S.ini();

    for(int i=1;i<=n;i++)

        row[i]=colum[i]=i;

    RH=RV=R=false;

    for(int i=0;i<q;i++)

    {

        scanf("%s",s);

        if(s[0]=='W')

        {

            scanf("%d%d%d",&r,&c,&v);

            change(r,c);

            S.change(r,c,v);

        }

        else if(s[0]=='C')

        {

            scanf("%d%d%d%d",&r1,&c1,&r2,&c2);

            change(r1,c1);

            change(r2,c2);

            S.change(r2,c2,S.back(r1,c1));

        }

        else if(s[0]=='S')

        {

            if(s[1]=='R')

            {

                scanf("%d%d",&r1,&r2);

                c1=c2=0;

                if(R)

                {

                    swap(r1,c1);

                    swap(r2,c2);

                }

                if(r1&&RH)r1=n+1-r1,r2=n+1-r2;

                if(c1&&RV)c1=n+1-c1,c2=n+1-c2;

                if(r1)swap(row[r1],row[r2]);

                if(c1)swap(colum[c1],colum[c2]);

            }

            else if(s[1]=='C')

            {

                scanf("%d%d",&c1,&c2);

                r1=r2=0;

                if(R)

                {

                    swap(r1,c1);

                    swap(r2,c2);

                }

                if(r1&&RH)r1=n+1-r1,r2=n+1-r2;

                if(c1&&RV)c1=n+1-c1,c2=n+1-c2;

                if(r1)swap(row[r1],row[r2]);

                if(c1)swap(colum[c1],colum[c2]);

            }

        }

        else if(s[0]=='R')

        {

            if(s[1]=='L')

            {

                if(R)RH=!RH;

                else RV=!RV;

                R=!R;

            }

            else if(s[1]=='R')

            {

                if(R)RV=!RV;

                else RH=!RH;

                R=!R;

            }

            else if(s[1]=='H')

            {

                if(!R)RH=!RH;

                else RV=!RV;

            }

            else if(s[1]=='V')

            {

                if(!R)RV=!RV;

                else RH=!RH;

            }

        }

    }

    long long ans=314159265LL;

    for(int i=D;i<=E;i++)

        for(int j=F;j<=G;j++)

        {

            r=i,c=j;

            change(r,c);

            ans=(ans*31+S.back(r,c))%mod;

        }

    printf("%d\n",(int)ans);

    return 0;

}