#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>

#define lson u<<1
#define rson u<<1|1
#define mid (l+r)>>1
#define lbranch l, mid, lson
#define rbranch mid+1, r, rson
#define MAXN 1050000
using namespace std;

struct SegTree{
    bool vis[30];
    int lazy;
    void init(){
        memset(vis, 0, sizeof(vis));
    }
}seg[MAXN<<2];
int n, m;

void build(int l, int r, int u){
    seg[u].lazy = -1;
    seg[u].init();
    if(l == r) return;
}

void PushUp(int u){
    for(int i=0; i<30; i++)
        seg[u].vis[i] = seg[lson].vis[i] | seg[rson].vis[i];
}

void PushDown(int l, int r, int u){
    if(seg[u].lazy != -1){
        seg[lson].init();
        seg[rson].init();
        seg[lson].lazy = seg[u].lazy;
        seg[rson].lazy = seg[u].lazy;
        seg[lson].vis[seg[u].lazy] = true;
        seg[rson].vis[seg[u].lazy] = true;
        seg[u].lazy = -1;
    }
}

void update(int ql, int qr, int color, int l, int r, int u){
    if(ql <= l && r <= qr){
        seg[u].lazy = color;
        seg[u].init();
        seg[u].vis[color] = true;
        return;
    }
    PushDown(l, r, u);
    if(ql <= mid) update(ql, qr, color, lbranch);
    if(qr > mid) update(ql, qr, color, rbranch);
    PushUp(u);
}

void query(int ql, int qr,int l, int r, int u, bool vis[]){
    if(ql <= l && r <= qr){
        for(int i=0; i<30; i++){
            vis[i] |= seg[u].vis[i];
        }
        return;
    }
    PushDown(l, r, u);
    if(ql <= mid) query(ql, qr, lbranch, vis);
    if(qr > mid)  query(ql, qr, rbranch, vis);
}

int main(){
    freopen("/home/acm/code/input.txt","r", stdin);
    while(cin>>n>>m){
        build(1, n, 1);
        while(m--){
            char ch[2];
            scanf("%s", ch);
            if(ch[0] == 'P'){
                int a, b, c;
                c--;
                scanf("%d %d %d", &a, &b, &c);
                update(a, b, c, 1, n, 1);
            }else{
                int a, b;
                scanf("%d %d", &a, &b);
                bool vis[30] = {0};
//                query(a, b, 1, n, 1, vis);
                bool first = true;
                for(int i=0; i<30; i++){
                    if(vis[i]){
                        if(!first){
                            printf(" ");
                        }else{
                            first = false;
                        }
                        printf("%d", i+1);
                    }
                }
            }
        }
    }
}