#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define repa(i,a,n) for(int i=a;i<a+n;++i)
#define repb(i,a,n) for(int i=a;i>a-n;--i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef long long ll;
typedef pair<int,int> P;
map<P,ll> mp;
ll N,Q,A,B,C,D,E,F,G;
ll mod=1e9+7;
int row[40001],col[40001];
ll initial(int r,int c){
	return (A*r+B*c)%C;
}
ll value(int r,int c){
	if(mp.find(P(r,c))==mp.end()){
		return initial(r,c);
	}else{
		return mp[P(r,c)];
	}
}
int ro,inv;
void change(int &r,int &c){
	int nr,nc;
	if(inv==0){
		if(ro==0) nr=r,nc=c;
		if(ro==1) nr=c,nc=N+1-r;
		if(ro==2) nr=N+1-r,nc=N+1-c;
		if(ro==3) nr=N+1-c,nc=r;
	}else{
		if(ro==0) nr=N+1-r,nc=c;
		if(ro==1) nr=N+1-c,nc=N+1-r;
		if(ro==2) nr=r,nc=N+1-c;
		if(ro==3) nr=c,nc=r;
	}
	r=row[nr],c=col[nc];
}
void change2(int &r,int &c){
	int nr,nc;
	if(inv==0){
		if(ro==0) nr=r,nc=c;
		if(ro==1) nr=c,nc=N+1-r;
		if(ro==2) nr=N+1-r,nc=N+1-c;
		if(ro==3) nr=N+1-c,nc=r;
	}else{
		if(ro==0) nr=N+1-r,nc=c;
		if(ro==1) nr=N+1-c,nc=N+1-r;
		if(ro==2) nr=r,nc=N+1-c;
		if(ro==3) nr=c,nc=r;
	}
	r=nr,c=nc;
}
void showmat(){
	show(ro);
	show(inv);
	for(int r=D;r<=E;r++){
		for(int c=F;c<=G;c++){
			int tmpr=r,tmpc=c;
			change(tmpr,tmpc);
			cout<<value(tmpr,tmpc)<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
}
int main(){
	cin>>N>>Q>>A>>B>>C>>D>>E>>F>>G;
	rep1(i,N) row[i]=i,col[i]=i;
	int X=E-D+1,Y=G-F+1;
	ro=0,inv=0;
	rep(i,Q){
		string type;
		cin>>type;
		if(type=="WR"){
			int r,c,v;
			cin>>r>>c>>v;
			change(r,c);
			mp[P(r,c)]=v;
		}
		if(type=="CP"){
			int r1,c1,r2,c2;
			cin>>r1>>c1>>r2>>c2;
			change(r1,c1);
			change(r2,c2);
			mp[P(r2,c2)]=value(r1,c1);
		}
		if(type=="SR"){
			int r1,r2,c1=0,c2=0;
			cin>>r1>>r2;
			change2(r1,c1);
			change2(r2,c2);
			// show(r1);
			// show(r2);
			// show(c1);
			// show(c2);
			if(c1==c2) swap(row[r1],row[r2]);
			if(r1==r2) swap(col[c1],col[c2]);
		}
		if(type=="SC"){
			int r1=0,r2=0,c1,c2;
			cin>>c1>>c2;
			change2(r1,c1);
			change2(r2,c2);
			if(c1==c2) swap(row[r1],row[r2]);
			if(r1==r2) swap(col[c1],col[c2]);
		}
		if(type=="RL"){
			ro=(ro+1)%4;
		}
		if(type=="RR"){
			ro=(ro+3)%4;
		}
		if(type=="RH"){
			if(ro%2==0){
				inv=1-inv;
			}else{
				inv=1-inv;
				ro=(ro+2)%4;
			}
		}
		if(type=="RV"){
			if(ro%2==0){
				inv=1-inv;
				ro=(ro+2)%4;
			}else{
				inv=1-inv;
			}
		}
//		showmat();
	}
	ll h=314159265;
	for(int r=D;r<=E;r++) for(int c=F;c<=G;c++){
		int tmpr=r,tmpc=c;
		change(tmpr,tmpc);
		h=h*31+value(tmpr,tmpc);
		h%=mod;
	}
	cout<<h<<endl;
}