#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define mid (l+r>>1)
#define lc (o<<1)
#define rc (o<<1|1)
using namespace std;
const int maxn = 1000010;

int sumv[maxn*4], st[maxn*4], ql, qr, v, _sum;
int n, ans[100], top;

void insert1(int o, int l, int r)
{
    if(ql <= l && r <= qr) {
        sumv[o] = st[o] = 1<<v;
        return;
    }
    if(st[o]) {
        st[lc] = st[rc] = st[o];
        sumv[lc] = sumv[rc] = st[o];
        st[o] = 0;
    }
    int m = mid;
    if(ql <= m) insert1(lc, l, m);
    if(qr >  m) insert1(rc, m+1, r);
    sumv[o] = sumv[lc] | sumv[rc];
    //printf("%d %d %d\n", l, r, sumv[o]);
}

void query(int o, int l, int r)
{
    if(st[o]) {
        _sum |= st[o];
        return;
    }
    if(ql <= l && r <= qr) {
        _sum |= sumv[o];
        return;
    }
    int m = mid;
    if(ql <= m) query(lc, l, m);
    if(qr >  m) query(rc, m+1, r);
}

int gao(int s)
{
    int i = 0;
    top = 0;
    while(s) {
        i++;
        if(s&1) ans[top++] = i;
        s >>= 1;
    }
}

int main()
{
    //freopen("b.txt", "r", stdin);
    //freopen("bout", "w", stdout);
    int m;
    while(scanf("%d%d", &n, &m), n)
    {
        //printf("%d %d\n", n, m);
        if(n == 0) break;
        memset(sumv, 0, sizeof sumv);
        memset(st, 0, sizeof st);
        char op[3];
        for(int i = 0; i < m; i++)
        {
            scanf("%s", op);
            if(op[0] == 'P') {
                scanf("%d%d%d", &ql, &qr, &v); v--;
                insert1(1, 1, n);
                //puts("");
            } else {
                scanf("%d%d", &ql, &qr);
                _sum = 0;
                query(1, 1, n);
                gao(_sum);
                for(int i = 0; i < top; i++) {
                    printf("%d%c", ans[i], i==top-1 ? '\n':' ');
                }
            }
        }
    }
    return 0;
}