/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
 * Date: 2014.05.28
 * OK, 1.4 sec, 16 mb
 */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

/** Main part */

const int N = 1e6;
const int PN = 4000;

ll sx[N + 1];
int qn, pn, n, mem[2][N], *x = mem[0], *y = mem[1];

struct Part {
  int i, n;
  ll sum() { return sx[i + n] - sx[i]; }
  void out() { forn(j, n) printf("%d ", x[i + j]); }
};

Part p[PN], q[PN];

void calc_sum() {
  forn(i, n)
    sx[i + 1] = sx[i] + x[i];
}

void build() {
  n = 0;
  forn(i, pn)
    memcpy(y + n, x + p[i].i, p[i].n * sizeof(x[0])), n += p[i].n;
  swap(x, y);
  calc_sum();
  pn = 0, p[pn++] = {0, n};
}

int split( int i ) {
  int j = 0;
  while (j < pn && i >= p[j].n)
    i -= p[j++].n;
  if (i) {
    for (int k = pn++; k > j; k--)
      p[k] = p[k - 1];
    p[j].n = i;
    p[++j].i += i, p[j].n -= i;
  }
  return j;
}

int main() {
  int A, B, M, k;
  scanf("%d%d%d%d%d%d", &n, &x[0], &A, &B, &M, &k);
  for (int i = 1; i < n; i++)
    x[i] = ((ll)x[i - 1] * A + B) % M;

  p[pn++] = {0, n};
  calc_sum();

  while (k --> 0) {
    char com[9];
    int l, r, l1, r1;
    scanf("%s%d%d", com, &l, &r), l--;
  	if (!strcmp(com, "cpy")) {
  	  scanf("%d", &l1);
  	  swap(r, l1), l1--;
  	  r1 = r + l1, r = r + l;
  	  l = split(l), r = split(r);
  	  memcpy(q, p + l, sizeof(p[0]) * (r - l));
  	  qn = r - l;
  	  l1 = split(l1), r1 = split(r1);
  	  memcpy(q + qn, p + r1, sizeof(p[0]) * (pn - r1));
  	  qn += pn - r1;
  	  memcpy(p + l1, q, sizeof(p[0]) * qn);
  	  pn = l1 + qn;
  	} else if (!strcmp(com, "sum")) {
  	  ll res = 0;
  	  for (int i = split(l), j = split(r); i < j; i++)
  	    res += p[i].sum();
  	  printf("%lld\n", res);
  	} else {
  	  for (int i = split(l), j = split(r); i < j; i++)
  	    p[i].out();
  	  puts("");
  	} 
    if (pn > PN / 2 - 10)
      build();
  }
  return 0;
}
