1 #include<cstdio>
2 #include<cstdlib>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #include<iostream>
7 #include<vector>
8 #include<map>
9 #include<set>
10 #include<queue>
11 #include<string>
12 #define inf 1000000000
13 #define maxn 1000000+100
14 #define maxm 100000+100
15 #define eps 1e-10
16 #define ll long long
17 #define pa pair<int,int>
18 #define for0(i,n) for(int i=0;i<=(n);i++)
19 #define for1(i,n) for(int i=1;i<=(n);i++)
20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
22 #define mod 20130426
23 using namespace std;
24 inline int read()
25 {
26 int x=0,f=1;char ch=getchar();
27 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
28 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
29 return x*f;
30 }
31 int q,rt,t1,t2,tot,s[maxn],c[maxn][2],fa[maxn];
32 ll v[maxn],t[maxn][2],ans,base;
33 inline void pushup(int x)
34 {
35 s[x]=s[c[x][0]]+s[c[x][1]]+1;
36 }
37 inline void rotate(int x,int &k)
38 {
39 int y=fa[x],z=fa[y],l=c[y][1]==x,r=l^1;
40 if(y!=k)c[z][c[z][1]==y]=x;else k=x;
41 fa[x]=z;fa[y]=x;fa[c[x][r]]=y;
42 c[y][l]=c[x][r];c[x][r]=y;
43 pushup(y);pushup(x);
44 }
45 inline void splay(int x,int &k)
46 {
47 while(x!=k)
48 {
49 int y=fa[x],z=fa[y];
50 if(y!=k)
51 {
52 if(c[z][0]==y^c[y][0]==x)rotate(x,k);else rotate(y,k);
53 }
54 rotate(x,k);
55 }
56 }
57 inline void update(int x,ll xx,ll yy)
58 {
59 if(!x)return;
60 (v[x]=v[x]*yy+xx)%=mod;
61 ((t[x][0]*=yy)+=xx)%=mod;
62 (t[x][1]*=yy)%=mod;
63 }
64 inline void pushdown(int x)
65 {
66 if(!x)return;
67 if(!t[x][0]&&t[x][1]==1)return;
68 update(c[x][0],t[x][0],t[x][1]);
69 update(c[x][1],t[x][0],t[x][1]);
70 t[x][0]=0;t[x][1]=1;
71 }
72 inline int find(int x,int k)
73 {
74 pushdown(x);
75 int l=c[x][0],r=c[x][1];
76 if(s[l]+1==k)return x;
77 else if(s[l]>=k)return find(l,k);
78 else return find(r,k-s[l]-1);
79 }
80 inline void split(int l,int r)
81 {
82 t1=find(rt,l);t2=find(rt,r);
83 splay(t1,rt);splay(t2,c[t1][1]);
84 }
85 inline void calc(int x)
86 {
87 if(!x)return;
88 pushdown(x);
89 calc(c[x][1]);
90 if(x!=1)ans=(ans*base+v[x])%mod;
91 calc(c[x][0]);
92 }
93 inline void build(int l,int r,int f)
94 {
95 if(l>r)return;
96 int x=(l+r)>>1;
97 fa[x]=f;c[f][x>f]=x;
98 s[x]=1;t[x][0]=0;t[x][1]=1;
99 if(l==r)return;
100 build(l,x-1,x);build(x+1,r,x);
101 pushup(x);
102 }
103 int main()
104 {
105 freopen("input.txt","r",stdin);
106 freopen("output.txt","w",stdout);
107 build(1,maxm,0);tot=maxm;rt=(1+maxm)>>1;
108 q=read();char ch[maxn];
109 while(q--)
110 {
111 scanf("%s",ch);
112 if(ch[0]==‘q‘)
113 {
114 ans=0;base=read()%mod;
115 calc(rt);
116 cout<<ans<<endl;
117 }
118 else
119 {
120 int x=read()+1,y=read()+1;
121 if(ch[3]==‘x‘)
122 {
123 split(y,y+3);
124 int z=c[t2][0],zz=c[z][0]+c[z][1];
125 pushdown(t1);pushdown(t2);pushdown(z);
126 v[z]+=v[zz];s[z]=1;
127 fa[zz]=c[z][0]=c[z][1]=0;
128 pushup(t2);pushup(t1);
129 split(x,x+1);
130 c[t2][0]=++tot;s[tot]=1;v[tot]=0;fa[tot]=t2;t[tot][1]=1;
131 pushup(t2);pushup(t1);
132 }
133 else if(ch[0]==‘m‘)
134 {
135 split(x,y+2);
136 ll xx=0,yy=read()%mod;
137 update(c[t2][0],xx,yy);
138 pushup(t2);pushup(t1);
139 }
140 else
141 {
142 split(x,y+2);
143 ll xx=read()%mod,yy=1;
144 update(c[t2][0],xx,yy);
145 pushup(t2);pushup(t1);
146 }
147 }
148 }
149 return 0;
150 }