//SORU xx
//PROGRAM C
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#include<time.h>
#include<ctype.h>
#define scn(x) fscanf(in,"%d",&x);
#define prn(x) fprintf(out,"%d\n",x);
#define prn2(x) fprintf(out,"%d",x);
#define line() fprintf(out,"\n");
#define wait system("PAUSE");
#define scn2(x,y) scn(x);scn(y);
FILE *in,*out;
void dosya(){
		/*in=fopen("girdi.in","r");*/in=stdin;
		/*out=fopen("cikti.out","w");*/out=stdout;
}
int N;
char c,t,temp;
int A[123][123];
void oku(){
	int kisi=0,top=0;
	while(fscanf(in,"%c",&c)!=EOF){
		if(c=='+') kisi++;
		else if(c=='-') kisi--;
		else if(c=='\n') continue;
		else{
			while(1){
				fscanf(in,"%c",&t);
				if(t=='\n') break;
				else if(t==':'){
					while(1){
						fscanf(in,"%c",&temp);
						if(temp=='\n') break;
						if(temp==' ');
						top+=kisi;
					}
					break;
					break;
				}
			}
		}
	}
	prn(top);
	return;
}
int main(){
	dosya();
	oku();
	return 0;
}


//SORU xx
//PROGRAM C
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#include<time.h>
#include<ctype.h>
//#include<math.h>
#define scn(x) fscanf(in,"%d",&x);
#define prn(x) fprintf(out,"%d\n",x);
#define prn2(x) fprintf(out,"%d",x);
#define line() fprintf(out,"\n");
#define wait system("PAUSE");
#define scn2(x,y) scn(x);scn(y);
FILE *in,*out;
void dosya(){
		/*in=fopen("girdi.in","r");*/in=stdin;
		/*out=fopen("cikti.out","w");*/out=stdout;
}
int N;
char c,t,temp;
void oku(){
	int kisi=0,top=0;
	while(fscanf(in,"%c",&c)!=EOF){
		if(c=='+') kisi++;
		else if(c=='-') kisi--;
		else{
			while(1){
				fscanf(in,"%c",&t);
				if(c==':'){
					while(1){
						fscanf(in,"%c",&temp);
						if(c=='\n') break;
						temp+=kisi;
					}
					break;
				}
				else if(c=='\n') break;
			}
		}
	}
}
int main(){
	dosya();
	oku();
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	int people=0,ans=0,i;
	char a;
	int d=0;
	while(1)
	{
		a=getchar();
		if(a==-1)
		{
		break;
		}
		if(a=='+')
			people++;
		if(a=='-')
			people--;
		if(a==':')
		{
		d=1;
		}
		else if(a=='\n')
		d=0;
		else if(d==1)
			ans=ans+people;
	}
	printf("%d",ans);
return 0;
}


#include <stdio.h>
#include <string.h>

#define MAX_SIZE 126

int main()
{
    int users = 0, bytes = 0, colon_position, commands_length;
    char commands[MAX_SIZE];

    while(fgets(commands, MAX_SIZE, stdin))
    {
        commands_length = strlen(commands);

        if(commands[0] == '+')
        {
            users++;
        }
        else if(commands[0] == '-')
        {
            users--;
        }
        else
        {
            colon_position = 0;
            while(colon_position < commands_length)
            {
                if(commands[colon_position] == ':')
                {
                    break;
                }
                colon_position++;
            }
            bytes += (commands_length-colon_position-2)*users;
        }
    }

    printf("%d\n", bytes);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXV = 111;

int n, m, inorder[MAXV];
int dp[MAXV][MAXV];

bool lhs[MAXV][MAXV], rhs[MAXV][MAXV];

bool solve(int l, int r) {
    if (l == r) {
        dp[l][r] = 0;
        for (int i = 1; i <= n; i++) if (lhs[l][i] || rhs[l][i]) return dp[l][r];
        dp[l][r] = 1;
        return dp[l][r];
    }
    if (dp[l][r] != -1) return dp[l][r];
    int lb = l, rb = r, &cur = dp[l][r];
    cur = 0;
    for (int i = 1; i <= n; i++) if (lhs[l][i]) {
        if (i < l || i > r) return cur;
        lb = i;
    }
    for (int i = n; i >= 1; i--) if (rhs[l][i]) {
        if (i < l || i > r) return cur;
        rb = i - 1;
    }
    if (lb > rb || lb > r || rb < l) {
        return cur;
    }
    if (rb == r && solve(l + 1, r)) {
        cur = 1;
        return cur;
    }
    if (lb == l && solve(l + 1, r)) {
        cur = 1;
        return cur;
    }
    for (int i = max(lb, l + 1); i <= min(rb, r - 1); i++) {
        int t1 = solve(l + 1, i), t2 = solve(i + 1, r);
        if (t1 > 0 && t2 > 0) {
            cur = 1;
            return cur;
        }
    }
    return cur;

}

void construct(int p1, int p2, int l, int r) {
    if (p1 == p2) {
        inorder[p1] = l;
        return ;
    }
    int lb = l, rb = r;
    for (int i = 1; i <= n; i++) if (lhs[l][i]) lb = i;
    for (int i = r; i >= 1; i--) if (rhs[l][i]) rb = i - 1;
    if (rb == r && solve(l + 1, r) > 0) {
        inorder[p2] = l;
        construct(p1, p2 - 1, l + 1, r);
        return ;
    }
    if (lb == l && solve(l + 1, r) > 0) {
        inorder[p1] = l;
        construct(p1 + 1, p2, l + 1, r);
        return ;
    }

    for (int i = max(lb, l + 1); i <= min(rb, r - 1); i++) {
        if (solve(l + 1, i) > 0 && solve(i + 1, r) > 0) {
            inorder[i - l + p1] = l;
            construct(p1, i - l + p1 - 1, l + 1, i);
            construct(i - l + p1 + 1, p2, i + 1, r);
            return ;
        }
    }
}

int main() {
   // freopen("test.in", "r", stdin);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        string str;
        cin >> a >> b >> str;
        if (b <= a) {
            puts("IMPOSSIBLE");
            return 0;
        }
        if (str == "LEFT")
            lhs[a][b] = true;
        else
            rhs[a][b] = true;
    }
    memset(dp, -1, sizeof(dp));
    if (solve(1, n) == 0) {
        puts("IMPOSSIBLE");
        return 0;
    }
    construct(1, n, 1, n);
    for (int i = 1; i <= n; i++) {
        i == n ? printf("%d\n", inorder[i]) : printf("%d ", inorder[i]);
    }
    return 0;
}


#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>
#else
#include <algorithm>
#include <bitset>
#include <list>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#endif

using namespace std;

	// lambda : [] (int a, int b) -> bool { body return }
	// string r_str = R"(raw string)"

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define LL long long
#define ULL unsigned long long
#define PI (atan(1) * 4)
#define BASE 73
#define NMAX 10000
#define NMAX2 20001
#define MOD1 1000000007
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define CRLINE Duxar(__LINE__);
#define SHOWME(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define ENTER putchar('\n');

int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};

int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};

void Duxar(int _this_line) {
#ifndef ONLINE_JUDGE
	printf("\n . . . . . . . . . . . . . Passed line - %d\n", _this_line);
#endif
}

bool AreEqual(double a, double b) {
	return (fabs(a - b) < 1e-10);
}

template <class T>
bool GetNr(T &_value) {
	T _sign = 1;
	char ch;
	_value = 0;
	while(!isdigit(ch = getchar())) {
		if (ch == -1) {
			return false;
		}
		ch == '-' ? _sign = -1 : _sign = 1 ;
	}
	do {
		_value = _value * 10 + (ch - '0');
	} while(isdigit(ch = getchar()));
	_value *= _sign;
	return true;
}

template <class T>
void PutNr(T _value, char _ch = ' ') {
	cout << _value << _ch;
}

int N, K, step, x, y;
string way;
vector <pair <int, int> > graph;
vector <int> visited;

bool DFS(int root) {
	int cnt = 0;
	while (cnt < 2) {
		if (x == 0) {
			if (step == K) {
				return true;
			}
			++step;
			GetNr(x); GetNr(y); cin >> way;
		}
		if (x == root) {
			if (way == "LEFT") {
				if (graph[root].first == 0 && visited[y] == 0) {
					graph[root].first = y;
					visited[y] = 1;
					x = 0;
					if (!DFS(y)) {
						return false;
					}
				}
				else {
					return false;
				}
			}
			else {
				if (graph[root].second == 0 && visited[y] == 0) {
					graph[root].second = y;
					if (graph[root].first == 0) {
						graph[root].first = -1;
					}
					visited[y] = 1;
					x = 0;
					if (!DFS(y)) {
						return false;
					}
				}
				else {
					return false;
				}
			}
		}
		else {
			return true;
		}

	}
	return true;
}

void InOrder(int root) {
	if (graph[root].first > 0) {
		InOrder(graph[root].first);
	}
	PutNr(root);
	if (graph[root].second > 0) {
		InOrder(graph[root].second);
	}
}

int main(){
	string fileInput = "sum";
#ifdef INFOARENA
	freopen((fileInput + ".in").c_str(), "r", stdin);
	freopen((fileInput + ".out").c_str(), "w", stdout);
#else
#ifndef ONLINE_JUDGE
	freopen("/Users/duxar/Workplace/Xcode Projects/Selectie/Selectie/input", "r", stdin);
		//	freopen("/Users/duxar/Workplace/Xcode Projects/Selectie/Selectie/result", "w", stdout);
#endif
#endif

	int i, x, y;
	string way;

	GetNr(N); GetNr(K);
	graph.resize(1 + N);
	visited.resize(1 + N);
	visited[1] = 1;
	if (!DFS(1)) {
		PutNr("IMPOSSIBLE", '\n');
		return 0;
	}

	if (step < K) {
		PutNr("IMPOSSIBLE", '\n');
		return 0;
	}

	if (x != 0) {
		PutNr("IMPOSSIBLE", '\n');
		return 0;
	}

	for (i = 1; i <= N; ++i) {
		if (!visited[i]) {
			PutNr("IMPOSSIBLE", '\n');
			return 0;
		}
	}

	InOrder(1);
	ENTER

		//	for (i = 0; i < K; ++i) {
		//		GetNr(x); GetNr(y); cin >> way;
		//
		//	}

	return 0;
}


#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>
#else
#include <algorithm>
#include <bitset>
#include <list>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#endif

using namespace std;

	// lambda : [] (int a, int b) -> bool { body return }
	// string r_str = R"(raw string)"

#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define LL long long
#define ULL unsigned long long
#define PI (atan(1) * 4)
#define BASE 73
#define NMAX 10000
#define NMAX2 20001
#define MOD1 1000000007
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define CRLINE Duxar(__LINE__);
#define SHOWME(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define ENTER putchar('\n');

int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};

int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};

void Duxar(int _this_line) {
#ifndef ONLINE_JUDGE
	printf("\n . . . . . . . . . . . . . Passed line - %d\n", _this_line);
#endif
}

bool AreEqual(double a, double b) {
	return (fabs(a - b) < 1e-10);
}

template <class T>
bool GetNr(T &_value) {
	T _sign = 1;
	char ch;
	_value = 0;
	while(!isdigit(ch = getchar())) {
		if (ch == -1) {
			return false;
		}
		ch == '-' ? _sign = -1 : _sign = 1 ;
	}
	do {
		_value = _value * 10 + (ch - '0');
	} while(isdigit(ch = getchar()));
	_value *= _sign;
	return true;
}

template <class T>
void PutNr(T _value, char _ch = ' ') {
	cout << _value << _ch;
}

int N, K;
vector <int> max_left, max_right, min_right, ans;

int Solve(int root, int last_mandatory, int first_bad) {
	if (last_mandatory < max_right[root]) {
		last_mandatory = max_right[root];
	}
	if (last_mandatory >= first_bad) {
		return 0;
	}

	int last_used = root;
	if (max_left[root]) {
		last_used = Solve(root + 1, max_left[root], min_right[root] != 1 + N ? min_right[root] : first_bad);
	}

	if (!last_used) {
		return 0;
	}

	ans.pb(root);

	if (last_mandatory >= last_used + 1) {
		return Solve(last_used + 1, last_mandatory, first_bad);
	}
	else {
		return last_used;
	}
}

int main(){
	string fileInput = "sum";
#ifdef INFOARENA
	freopen((fileInput + ".in").c_str(), "r", stdin);
	freopen((fileInput + ".out").c_str(), "w", stdout);
#else
#ifndef ONLINE_JUDGE
	freopen("/Users/duxar/Workplace/Xcode Projects/Selectie/Selectie/input", "r", stdin);
	//	freopen("/Users/duxar/Workplace/Xcode Projects/Selectie/Selectie/result", "w", stdout);
#endif
#endif

	int i, x, y;
	string way;

	GetNr(N); GetNr(K);
	max_left.resize(1 + N);
	max_right.resize(1 + N);
	min_right.resize(1 + N, 1 + N);

	for (i = 0; i < K; ++i) {
		GetNr(x); GetNr(y); cin >> way;

		if (x >= y) {
			PutNr("IMPOSSIBLE", '\n');
			return 0;
		}

		if (way == "LEFT") {
			max_left[x] = max(max_left[x], y);
		}
		else {
			min_right[x] = min(min_right[x], y);
			max_right[x] = max(max_right[x], y);
		}

		if (min_right[x] && max_left[x] > min_right[x]) {
			PutNr("IMPOSSIBLE", '\n');
			return 0;
		}
	}

	if (!Solve(1, N, 1 + N)) {
		PutNr("IMPOSSIBLE", '\n');
		return 0;
	}
	else {
		for (auto x: ans) {
			PutNr(x);
		}
		ENTER
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)for(int i=a;i<int(b);i++)
int N,C;struct node{int max,L=INT_MIN,R=INT_MAX;}nds[1000000];void fail(){puts("IMPOSSIBLE");exit(0);}vector<int>odr;int inorder(int n,int nMax){int cn=n+1;if(cn<=nds[n].L)cn=inorder(cn,nds[n].L);if(cn>nds[n].R)fail();odr.push_back(n);int R=max(nMax,nds[n].max);if(cn<=R)cn=inorder(cn,R);return cn;}int main(){scanf("%d%d",&N,&C);FOR(c,0,C){char s[10];int a,b;scanf("%d%d%s",&a,&b,s);a--;b--;if(b<=a)fail();nds[a].max=max(nds[a].max,b);if(s[0]=='L'){nds[a].L=max(nds[a].L,b);}else{nds[a].R=min(nds[a].R,b);}}inorder(0,N-1);for(int x : odr)printf("%d ",x+1);putchar('\n');}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=a;i<int(b);i++)

int N, C;
struct node {
	int max, L = INT_MIN, R = INT_MAX;
} nds[1000000];

void fail() {
	puts("IMPOSSIBLE");
	exit(0);
}

vector<int> odr;
int inorder(int n, int nMax) {
	int cn = n+1;
	if (cn <= nds[n].L) cn = inorder(cn, nds[n].L);
	if (cn > nds[n].R) fail();
	odr.push_back(n);
	int R = max(nMax, nds[n].max);
	if (cn <= R) cn = inorder(cn, R);
	return cn;
}

int main() {
	scanf("%d%d", &N, &C);
	FOR(c, 0, C) {
		char s[10];
		int a, b;
		scanf("%d%d%s", &a, &b, s);
		a--; b--;
		if (b <= a) fail();
		nds[a].max = max(nds[a].max, b);
		if (s[0] == 'L') {
			nds[a].L = max(nds[a].L, b);
		} else {
			nds[a].R = min(nds[a].R, b);
		}
	}
	inorder(0, N-1);
	for (int x : odr) printf("%d ", x+1);
	putchar('\n');
}


//thank you Tourist :D

#include<bits/stdc++.h>

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second

#define LEFT 0
#define RIGHT 1

const int N = 1234567;

int fenw[N];

void modify(int x, int v) {
  while (x < N) {
    fenw[x] += v;
    x = (x | (x - 1)) + 1;
  }
}

int find_sum(int x) {
  int v = 0;
  while (x > 0) {
    v += fenw[x];
    x &= x - 1;
  }
  return v;
}

int a[N], b[N], dir[N];
int k;
vector <int> ret;
vector <int> g[N];

void solve(int root, int to) {
  if (root > to) {
    return;
  }
  if (root == to) {
    ret.push_back(root);
    return;
  }
  int sz = g[root].size();
  int sfrom = root;
  int sto = to;
  for (int q = 0; q < sz; q++) {
    int j = g[root][q];
    if (dir[j] == LEFT) {
      if (b[j] > sfrom) {
        sfrom = b[j];
      }
    }
    if (dir[j] == RIGHT) {
      if (b[j] - 1 < sto) {
        sto = b[j] - 1;
      }
    }
    modify(a[j], -1);
    modify(b[j], 1);
  }
  int parity = 0;
  while (sfrom <= sto) {
    if (parity) {
      if (find_sum(sfrom) == 0) {
        solve(root + 1, sfrom);
        ret.push_back(root);
        solve(sfrom + 1, to);
        return;
      }
      sfrom++;
    } else {
      if (find_sum(sto) == 0) {
        solve(root + 1, sto);
        ret.push_back(root);
        solve(sto + 1, to);
        return;
      }
      sto--;
    }
    parity ^= 1;
  }
  puts("IMPOSSIBLE");
  exit(0);
}

int main() {
  int n;
  scanf("%d %d", &n, &k);
  char foo[42];
  for (int i = 1; i <= n; i++) {
    fenw[i] = 0;
    g[i].clear();
  }
  for (int i = 0; i < k; i++) {
    scanf("%d %d %s", a + i, b + i, foo);
    if (a[i] < 1 || a[i] > n || b[i] < 1 || b[i] > n || b[i] <= a[i]) {
      puts("IMPOSSIBLE");
      return 0;
    }
    dir[i] = (foo[0] == 'L' ? LEFT : RIGHT);
    modify(a[i], 1);
    modify(b[i], -1);
    g[a[i]].push_back(i);
  }
  ret.clear();
  solve(1, n);
  for (int i = 0; i < n - 1; i++) {
    printf("%d ", ret[i]);
  }
  printf("%d\n", ret[n - 1]);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef pair<int, int> pii;

const int MAXN = 1<<20;

int n, c;
char s[10];
vector<int> adj[MAXN][2];

pii tree[2*MAXN]; //min, pos
int lazy[2*MAXN];

void down(int cur, int lt, int rt) {
    tree[cur].fi += lazy[cur];
    if (lt + 1 != rt) {
        lazy[2*cur] += lazy[cur];
        lazy[2*cur+1] += lazy[cur];
    }
    lazy[cur] = 0;
}

pii merge(pii p1, pii p2) {
    if (p1.fi <= p2.fi) return p1;
    else return p2;
}

void init(int cur, int lt, int rt) {
    tree[cur] = pii(0, lt);
    if (lt + 1 != rt) {
        int mid = (lt + rt) / 2;
        init(2*cur, lt, mid);
        init(2*cur+1, mid, rt);
    }
}

void upd(int cur, int lt, int rt, int ql, int qr, int v) {
    down(cur, lt, rt);
    if (rt <= ql || lt >= qr) return;
    else if (lt >= ql && rt <= qr) {
        lazy[cur] = v;
        down(cur, lt, rt);
    } else {
        int mid = (lt + rt) / 2;
        upd(2*cur, lt, mid, ql, qr, v);
        upd(2*cur+1, mid, rt, ql, qr, v);
        tree[cur] = merge(tree[2*cur], tree[2*cur+1]);
    }
}

pii qry(int cur, int lt, int rt, int ql, int qr) {
    down(cur, lt, rt);
    if (rt <= ql || lt >= qr) return pii(1e9, -1);
    else if (lt >= ql && rt <= qr) return tree[cur];
    else {
        int mid = (lt + rt) / 2;
        return merge(qry(2*cur, lt, mid, ql, qr), qry(2*cur+1, mid, rt, ql, qr));
    }
}

int chd[MAXN][2];

void abort() {
    printf("IMPOSSIBLE\n");
    exit(0);
}

void dfs(int lt, int rt) {
    if (lt + 1 == rt) return;
    for (int i=0; i<2; i++)
        for (int j : adj[lt][i])
            upd(1, 1, n+1, lt+1, j+1, -1);

    int l = lt+1, r = rt;
    if (!adj[lt][0].empty()) l = adj[lt][0].back()+1;
    if (!adj[lt][1].empty()) r = adj[lt][1].front()+1;

    if (l>r) abort();
    pii p = qry(1, 1, n+1, l, r);
    if (p.fi != 0) abort();
    int k = p.se;

    if (k > lt+1) {
        chd[lt][0] = lt+1;
        dfs(lt+1, k);
    }
    if (k < rt) {
        chd[lt][1] = k;
        dfs(k, rt);
    }
}

void dfs2(int cur) {
    if (!cur) return;
    dfs2(chd[cur][0]);
    printf("%d ", cur);
    dfs2(chd[cur][1]);
}

int main() {
    if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);

    scanf("%d %d\n", &n, &c);
    init(1, 1, n+1);
    for (int i=0; i<c; i++) {
        int a, b;
        scanf("%d %d %s\n", &a, &b, s);
        if (a>b) abort();
        if (s[0] == 'L') adj[a][0].push_back(b);
        else adj[a][1].push_back(b);
        upd(1, 1, n+1, a+1, b+1, 1);
    }

    for (int i=1; i<=n; i++)
        for (int j=0; j<2; j++)
            sort(adj[i][j].begin(), adj[i][j].end());

    dfs(1, n+1);
    dfs2(1);
}


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef pair<int, int> pii;

const int MAXN = 1<<20;

int n, c;
char s[10];
vector<int> adj[MAXN][2];

pii tree[2*MAXN]; //min, pos
int lazy[2*MAXN];

void down(int cur, int lt, int rt) {
    tree[cur].fi += lazy[cur];
    if (lt + 1 != rt) {
        lazy[2*cur] += lazy[cur];
        lazy[2*cur+1] += lazy[cur];
    }
    lazy[cur] = 0;
}

pii merge(pii p1, pii p2) {
    if (p1.fi <= p2.fi) return p1;
    else return p2;
}

void init(int cur, int lt, int rt) {
    tree[cur] = pii(0, lt);
    if (lt + 1 != rt) {
        int mid = (lt + rt) / 2;
        init(2*cur, lt, mid);
        init(2*cur+1, mid, rt);
    }
}

void upd(int cur, int lt, int rt, int ql, int qr, int v) {
    down(cur, lt, rt);
    if (rt <= ql || lt >= qr) return;
    else if (lt >= ql && rt <= qr) {
        lazy[cur] = v;
        down(cur, lt, rt);
    } else {
        int mid = (lt + rt) / 2;
        upd(2*cur, lt, mid, ql, qr, v);
        upd(2*cur+1, mid, rt, ql, qr, v);
        tree[cur] = merge(tree[2*cur], tree[2*cur+1]);
    }
}

pii qry(int cur, int lt, int rt, int ql, int qr) {
    down(cur, lt, rt);
    if (rt <= ql || lt >= qr) return pii(1e9, -1);
    else if (lt >= ql && rt <= qr) return tree[cur];
    else {
        int mid = (lt + rt) / 2;
        return merge(qry(2*cur, lt, mid, ql, qr), qry(2*cur+1, mid, rt, ql, qr));
    }
}

int chd[MAXN][2];

void abort() {
    printf("IMPOSSIBLE\n");
    exit(0);
}

void dfs(int lt, int rt) {
    if (lt + 1 == rt) return;
    for (int i=0; i<2; i++)
        for (int j : adj[lt][i])
            upd(1, 1, n+1, lt+1, j+1, -1);

    int l = lt+1, r = rt;
    if (!adj[lt][0].empty()) l = adj[lt][0].back()+1;
    if (!adj[lt][1].empty()) r = adj[lt][1].front()+1;

    if (l>=r) abort();
    pii p = qry(1, 1, n+1, l, r);
    if (p.fi != 0) abort();
    int k = p.se;

    if (k > lt+1) {
        chd[lt][0] = lt+1;
        dfs(lt+1, k);
    }
    if (k < rt) {
        chd[lt][1] = k;
        dfs(k, rt);
    }
}

void dfs2(int cur) {
    if (!cur) return;
    dfs2(chd[cur][0]);
    printf("%d ", cur);
    dfs2(chd[cur][1]);
}

int main() {
    if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);

    scanf("%d %d\n", &n, &c);
    init(1, 1, n+1);
    for (int i=0; i<c; i++) {
        int a, b;
        scanf("%d %d %s\n", &a, &b, s);
        if (a>b) abort();
        if (s[0] == 'L') adj[a][0].push_back(b);
        else adj[a][1].push_back(b);
        upd(1, 1, n+1, a+1, b+1, 1);
    }

    for (int i=1; i<=n; i++)
        for (int j=0; j<2; j++)
            sort(adj[i][j].begin(), adj[i][j].end());

    dfs(1, n+1);
    dfs2(1);
}


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef pair<int, int> pii;

const int MAXN = 1<<20;

int n, c;
char s[10];
vector<int> adj[MAXN][2];

pii tree[2*MAXN]; //min, pos
int lazy[2*MAXN];

void down(int cur, int lt, int rt) {
    tree[cur].fi += lazy[cur];
    if (lt + 1 != rt) {
        lazy[2*cur] += lazy[cur];
        lazy[2*cur+1] += lazy[cur];
    }
    lazy[cur] = 0;
}

pii merge(pii p1, pii p2) {
    if (p1.fi <= p2.fi) return p1;
    else return p2;
}

void init(int cur, int lt, int rt) {
    tree[cur] = pii(0, lt);
    if (lt + 1 != rt) {
        int mid = (lt + rt) / 2;
        init(2*cur, lt, mid);
        init(2*cur+1, mid, rt);
    }
}

void upd(int cur, int lt, int rt, int ql, int qr, int v) {
    down(cur, lt, rt);
    if (rt <= ql || lt >= qr) return;
    else if (lt >= ql && rt <= qr) {
        lazy[cur] = v;
        down(cur, lt, rt);
    } else {
        int mid = (lt + rt) / 2;
        upd(2*cur, lt, mid, ql, qr, v);
        upd(2*cur+1, mid, rt, ql, qr, v);
        tree[cur] = merge(tree[2*cur], tree[2*cur+1]);
    }
}

pii qry(int cur, int lt, int rt, int ql, int qr) {
    down(cur, lt, rt);
    if (rt <= ql || lt >= qr) return pii(1e9, -1);
    else if (lt >= ql && rt <= qr) return tree[cur];
    else {
        int mid = (lt + rt) / 2;
        return merge(qry(2*cur, lt, mid, ql, qr), qry(2*cur+1, mid, rt, ql, qr));
    }
}

int chd[MAXN][2];

void abort() {
    printf("IMPOSSIBLE\n");
    exit(0);
}

void dfs(int lt, int rt) {
    for (int i=0; i<2; i++)
        for (int j : adj[lt][i])
            upd(1, 1, n+2, lt+1, j+1, -1);

    int l = lt+1, r = rt+1;
    if (!adj[lt][0].empty()) l = adj[lt][0].back()+1;
    if (!adj[lt][1].empty()) r = adj[lt][1].front()+1;

    if (l>=r) abort();
    pii p = qry(1, 1, n+2, l, r);
    if (p.fi != 0) abort();
    int k = p.se;

    if (k > lt+1) {
        chd[lt][0] = lt+1;
        dfs(lt+1, k);
    }
    if (k < rt) {
        chd[lt][1] = k;
        dfs(k, rt);
    }
}

void dfs2(int cur) {
    if (!cur) return;
    dfs2(chd[cur][0]);
    printf("%d ", cur);
    dfs2(chd[cur][1]);
}

int main() {
    if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);

    scanf("%d %d\n", &n, &c);
    init(1, 1, n+2);
    for (int i=0; i<c; i++) {
        int a, b;
        scanf("%d %d %s\n", &a, &b, s);
        if (a>b) abort();
        if (s[0] == 'L') adj[a][0].push_back(b);
        else adj[a][1].push_back(b);
        upd(1, 1, n+2, a+1, b+1, 1);
    }

    for (int i=1; i<=n; i++)
        for (int j=0; j<2; j++)
            sort(adj[i][j].begin(), adj[i][j].end());

    dfs(1, n+1);
    dfs2(1);
}


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef pair<int, int> pii;

const int MAXN = 1<<20;

int n, c;
char s[10];
vector<int> adj[MAXN][2];

pii tree[2*MAXN]; //min, pos
int lazy[2*MAXN];

void down(int cur, int lt, int rt) {
    tree[cur].fi += lazy[cur];
    if (lt + 1 != rt) {
        lazy[2*cur] += lazy[cur];
        lazy[2*cur+1] += lazy[cur];
    }
    lazy[cur] = 0;
}

pii merge(pii p1, pii p2) {
    if (p1.fi <= p2.fi) return p1;
    else return p2;
}

void init(int cur, int lt, int rt) {
    tree[cur] = pii(0, lt);
    if (lt + 1 != rt) {
        int mid = (lt + rt) / 2;
        init(2*cur, lt, mid);
        init(2*cur+1, mid, rt);
    }
}

void upd(int cur, int lt, int rt, int ql, int qr, int v) {
    down(cur, lt, rt);
    if (rt <= ql || lt >= qr) return;
    else if (lt >= ql && rt <= qr) {
        lazy[cur] = v;
        down(cur, lt, rt);
    } else {
        int mid = (lt + rt) / 2;
        upd(2*cur, lt, mid, ql, qr, v);
        upd(2*cur+1, mid, rt, ql, qr, v);
        tree[cur] = merge(tree[2*cur], tree[2*cur+1]);
    }
}

pii qry(int cur, int lt, int rt, int ql, int qr) {
    down(cur, lt, rt);
    if (rt <= ql || lt >= qr) return pii(1e9, -1);
    else if (lt >= ql && rt <= qr) return tree[cur];
    else {
        int mid = (lt + rt) / 2;
        return merge(qry(2*cur, lt, mid, ql, qr), qry(2*cur+1, mid, rt, ql, qr));
    }
}

int chd[MAXN][2];

void abort() {
    printf("IMPOSSIBLE\n");
    exit(0);
}

void dfs(int lt, int rt) {
    for (int i=0; i<2; i++)
        for (int j : adj[lt][i])
            upd(1, 1, n+2, lt+1, j+1, -1);

    int l = lt+1, r = rt+1;
    if (!adj[lt][0].empty()) l = adj[lt][0].back()+1;
    if (!adj[lt][1].empty()) r = adj[lt][1].front()+1;

    if (l>=r) abort();
    pii p = qry(1, 1, n+2, l, r);
    if (p.fi != 0) abort();
    int k = p.se;

    if (k > lt+1) {
        chd[lt][0] = lt+1;
        dfs(lt+1, k);
    }
    if (k < rt) {
        chd[lt][1] = k;
        dfs(k, rt);
    }
}

void dfs2(int cur) {
    if (!cur) return;
    dfs2(chd[cur][0]);
    printf("%d ", cur);
    dfs2(chd[cur][1]);
}

int main() {
    if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);

    scanf("%d %d\n", &n, &c);
    init(1, 1, n+2);
    for (int i=0; i<c; i++) {
        int a, b;
        scanf("%d %d %s\n", &a, &b, s);
        if (a>=b) abort();
        if (s[0] == 'L') adj[a][0].push_back(b);
        else adj[a][1].push_back(b);
        upd(1, 1, n+2, a+1, b+1, 1);
    }

    for (int i=1; i<=n; i++)
        for (int j=0; j<2; j++)
            sort(adj[i][j].begin(), adj[i][j].end());

    dfs(1, n+1);
    dfs2(1);
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=a;i<int(b);i++)

int N, C;
struct node {
	int max, L = INT_MIN, R = INT_MAX;
} nds[1000000];

void fail() {
	puts("IMPOSSIBLE");
	exit(0);
}

vector<int> odr;
int inorder(int n, int nMax) {
	int cn = n+1;
	if (cn <= nds[n].L) cn = inorder(cn, nds[n].L);
	if (cn > nds[n].R) fail();
	odr.push_back(n);
	int R = max(nMax, nds[n].max);
	if (cn <= R) cn = inorder(cn, R);
	return cn;
}

int main() {
	scanf("%d%d", &N, &C);
	FOR(c, 0, C) {
		char s[10];
		int a, b;
		scanf("%d%d%s", &a, &b, s);
		a--; b--;
		if (b <= a) fail();
		nds[a].max = max(nds[a].max, b);
		if (s[0] == 'L') {
			nds[a].L = max(nds[a].L, b);
		} else {
			nds[a].R = min(nds[a].R, b);
		}
	}
	inorder(0, N-1);
	for (int x : odr) printf("%d ", x+1);
	putchar('\n');
}
//hellobig_tq


#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define INPUT freopen("draft.inp","r",stdin)
#define OUTPUT freopen("draft.out","w",stdout)
#define FOR(i,l,r) for(auto i=l;i<=r;i++)
#define REP(i,l,r) for(auto i=l;i<r;i++)
#define FORD(i,l,r) for(auto i=l;i>=r;i--)
#define REPD(i,l,r) for(auto i=l;i>r;i--)
#define ENDL printf("\n")
#define debug 1

typedef long long ll;
typedef pair<int,int> ii;

const int inf=1e9;
const int MOD=1e9+7;
const int N=1e6+10;

vector <int> a[N][2],ans;
int n,m,x,y,h[N],cur=0,nex=1;
char s[10];
void DFS(int R,int x){
//    printf("%d %d %d\n",x,nex,cur);
    int nR=0;
    for(auto i:a[x][0]) {
        h[i]=1,cur++;
        nR=max(nR,i);
    }
    if (nex<nR) DFS(nR,++nex);
    if (h[x]) cur--,h[x]=0;
//    printf("%d %d %d\n",x,nex,cur);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    if (cur){
        printf("IMPOSSIBLE");
        exit(0);
    }
    for(auto i:a[x][1]) h[i]=1,cur++;
    ans.push_back(x);
    if (nex<R) DFS(R,++nex);
}
void solve(){
    DFS(n,1);
    for(auto i:ans) printf("%d ",i);
}
int main(){
    scanf("%d%d\n",&n,&m);
    while (m--){
        scanf("%d%d%s",&x,&y,s);
//        printf("%d %d %s\n",x,y,s);
        a[x][s[0]=='R'].push_back(y);
    }
    solve();
}


#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define INPUT freopen("draft.inp","r",stdin)
#define OUTPUT freopen("draft.out","w",stdout)
#define FOR(i,l,r) for(auto i=l;i<=r;i++)
#define REP(i,l,r) for(auto i=l;i<r;i++)
#define FORD(i,l,r) for(auto i=l;i>=r;i--)
#define REPD(i,l,r) for(auto i=l;i>r;i--)
#define ENDL printf("\n")
#define debug 1
#define WRONG {printf("IMPOSSIBLE");exit(0);}

typedef long long ll;
typedef pair<int,int> ii;

const int inf=1e9;
const int MOD=1e9+7;
const int N=1e6+10;

vector <int> a[N][2],ans;
int n,m,x,y,h[N],cur=0,nex=1,pos[N];
char s[10];
void DFS(int R,int x){
    h[x]=3;
    FOR(j,0,1)
        for(auto i:a[x][j]){
            if (h[i]>=2) WRONG;
            h[i]=1+j;
        }
//    printf("%d %d %d\n",x,nex,R);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    if (!a[x][0].empty()&&nex<a[x][0].back()) DFS(a[x][0].back(),++nex);
    for(auto i:a[x][0]) if (h[i]!=3) WRONG;
    for(auto i:a[x][1]) {
        if (h[i]==3) WRONG;
        h[i]=1;
    }
//    printf("%d %d %d\n",x,nex,R);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    ans.push_back(x);
    if (!a[x][1].empty()) R=max(R,a[x][1].back());
    if (nex<R) DFS(R,++nex);
    for(auto i:a[x][1]) if (h[i]!=3) WRONG;
}
void solve(){
    h[n+1]=2;
    DFS(n,1);
    for(auto i:ans) printf("%d ",i);
}
int main(){
//    INPUT;
    scanf("%d%d\n",&n,&m);
    while (m--){
        scanf("%d%d%s",&x,&y,s);
//        printf("%d %d %s\n",x,y,s);
        a[x][s[0]=='R'].push_back(y);
    }
    FOR(i,1,n)
        FOR(j,0,1) {
            sort(a[i][j].begin(),a[i][j].end());
            a[i][j].resize(unique(a[i][j].begin(),a[i][j].end())-a[i][j].begin());
        }
    solve();
}


#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define INPUT freopen("draft.inp","r",stdin)
#define OUTPUT freopen("draft.out","w",stdout)
#define FOR(i,l,r) for(auto i=l;i<=r;i++)
#define REP(i,l,r) for(auto i=l;i<r;i++)
#define FORD(i,l,r) for(auto i=l;i>=r;i--)
#define REPD(i,l,r) for(auto i=l;i>r;i--)
#define ENDL printf("\n")
#define debug 1
#define WRONG {printf("IMPOSSIBLE");exit(0);}

typedef long long ll;
typedef pair<int,int> ii;

const int inf=1e9;
const int MOD=1e9+7;
const int N=1e6+10;

vector <int> a[N][2],ans;
int n,m,x,y,h[N],cur=0,nex=1,pos[N];
char s[10];
void DFS(int x){
    h[x]=3;
    for(auto i:a[x][0]){
        if (h[i]>=2) WRONG;
        h[i]=1;
    }
    for(auto i:a[x][1]) {
        if (h[i]>=2) WRONG;
        h[i]=2;
    }
//    printf("%d %d\n",x,nex);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    if (h[nex+1]!=2) DFS(++nex);

    for(auto i:a[x][0]) if (h[i]!=3) WRONG;
    for(auto i:a[x][1]) h[i]=1;
//    printf("%d %d\n",x,nex);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    ans.push_back(x);
    if (h[nex+1]!=2) DFS(++nex);
}
void solve(){
    h[n+1]=2;
    DFS(1);
    for(auto i:ans) printf("%d ",i);
}
int main(){
//    INPUT;
    scanf("%d%d\n",&n,&m);
    while (m--){
        scanf("%d%d%s",&x,&y,s);
//        printf("%d %d %s\n",x,y,s);
        a[x][s[0]=='R'].push_back(y);
    }
    FOR(i,1,n)
        FOR(j,0,1) {
            sort(a[i][j].begin(),a[i][j].end());
            a[i][j].resize(unique(a[i][j].begin(),a[i][j].end())-a[i][j].begin());
        }
    solve();
}


#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define INPUT freopen("draft.inp","r",stdin)
#define OUTPUT freopen("draft.out","w",stdout)
#define FOR(i,l,r) for(auto i=l;i<=r;i++)
#define REP(i,l,r) for(auto i=l;i<r;i++)
#define FORD(i,l,r) for(auto i=l;i>=r;i--)
#define REPD(i,l,r) for(auto i=l;i>r;i--)
#define ENDL printf("\n")
#define debug 1
#define WRONG {printf("IMPOSSIBLE");exit(0);}

typedef long long ll;
typedef pair<int,int> ii;

const int inf=1e9;
const int MOD=1e9+7;
const int N=1e6+10;

vector <int> a[N][2],ans;
int n,m,x,y,h[N],cur=0,nex=1,pos[N];
char s[10];
void DFS(int R,int x){
    h[x]=3;
    for(auto i:a[x][0]){
        if (h[i]>=2) WRONG;
        h[i]=1;
    }
    for(auto i:a[x][1]) {
        if (h[i]>=2) WRONG;
        h[i]=2;
    }
//    printf("%d %d %d\n",x,nex,R);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    if (!a[x][0].empty()&&nex<a[x][0].back()) DFS(a[x][0].back(),++nex);
    for(auto i:a[x][0]) if (h[i]!=3) WRONG;
    for(auto i:a[x][1]) h[i]=1;
//    printf("%d %d %d\n",x,nex,R);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    ans.push_back(x);
    if (nex<R) DFS(R,++nex);
}
void solve(){
    h[n+1]=2;
    DFS(n,1);
    for(auto i:ans) printf("%d ",i);
}
int main(){
//    INPUT;
    scanf("%d%d\n",&n,&m);
    while (m--){
        scanf("%d%d%s",&x,&y,s);
//        printf("%d %d %s\n",x,y,s);
        a[x][s[0]=='R'].push_back(y);
    }
    FOR(i,1,n)
        FOR(j,0,1) {
            sort(a[i][j].begin(),a[i][j].end());
            a[i][j].resize(unique(a[i][j].begin(),a[i][j].end())-a[i][j].begin());
        }
    solve();
}


#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define INPUT freopen("draft.inp","r",stdin)
#define OUTPUT freopen("draft.out","w",stdout)
#define FOR(i,l,r) for(auto i=l;i<=r;i++)
#define REP(i,l,r) for(auto i=l;i<r;i++)
#define FORD(i,l,r) for(auto i=l;i>=r;i--)
#define REPD(i,l,r) for(auto i=l;i>r;i--)
#define ENDL printf("\n")
#define debug 1
#define WRONG {printf("IMPOSSIBLE");exit(0);}

typedef long long ll;
typedef pair<int,int> ii;

const int inf=1e9;
const int MOD=1e9+7;
const int N=1e6+10;

vector <int> a[N][2],ans;
int n,m,x,y,h[N],cur=0,nex=1,pos[N];
char s[10];
void DFS(int R,int x){
    h[x]=3;
    FOR(j,0,1)
        for(auto i:a[x][0]){
            if (h[i]>=2) WRONG;
            h[i]=1+j;
        }
//    printf("%d %d %d\n",x,nex,R);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    if (!a[x][0].empty()&&nex<a[x][0].back()) DFS(a[x][0].back(),++nex);
    for(auto i:a[x][0]) if (h[i]!=3) WRONG;
    for(auto i:a[x][1]) {
        if (h[i]==3) WRONG;
        h[i]=1;
    }
//    printf("%d %d %d\n",x,nex,R);
//    FOR(i,1,n) printf("%d ",h[i]);ENDL;
    ans.push_back(x);
    if (!a[x][1].empty()) R=max(R,a[x][1].back());
    if (nex<R) DFS(R,++nex);
    for(auto i:a[x][1]) if (h[i]!=3) WRONG;
}
void solve(){
    h[n+1]=2;
    DFS(n,1);
    for(auto i:ans) printf("%d ",i);
}
int main(){
//    INPUT;
    scanf("%d%d\n",&n,&m);
    while (m--){
        scanf("%d%d%s",&x,&y,s);
//        printf("%d %d %s\n",x,y,s);
        a[x][s[0]=='R'].push_back(y);
    }
    FOR(i,1,n)
        FOR(j,0,1) {
            sort(a[i][j].begin(),a[i][j].end());
            a[i][j].resize(unique(a[i][j].begin(),a[i][j].end())-a[i][j].begin());
        }
    solve();
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <memory.h>
#include <stack>
#include <fstream>
#include <cstdio>
#include <unordered_map>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

/*
*/

int n;
vector<vector<int> > L;
vector<vector<int> > R;
vector<vector<int> > tr;

int solve(int i, int end)
{
	int extendL = i;
	for (int j = 0; j < L[i].size(); j++)
	{
		extendL = max(extendL, L[i][j]);
		if (L[i][j] < i) return -1;
	}
	int startR = i;
	if (extendL > i)
	{
		tr[i][0] = i+1;
		startR = solve(i+1, extendL);
		if (startR == -1) return -1;
	}
	int extendR = max(end, startR);
	for (int j = 0; j < R[i].size(); j++)
	{
		extendR = max(extendR, R[i][j]);
		if (R[i][j] < startR) return -1;
	}
	int fin = startR;
	startR++;
	if (extendR >= startR)
	{
		tr[i][1] = startR;
		fin = solve(startR, extendR);
		if (fin == -1) return -1;
	}
	return fin;
}

void show(int i)
{
	if (i == -1) return;
	show(tr[i][0]);
	cout<<" "<<i+1;
	show(tr[i][1]);
}
int main()
{
	int c;
	cin>>n>>c;
	tr = vector<vector<int> > (n, vector<int> (2, -1));
	L = vector<vector<int> > (n);
	R = vector<vector<int> > (n);
	for (int i = 0; i < c; i++)
	{
		int a, b;
		string side;
		cin>>a>>b>>side;
		a--;
		b--;
		if (a >= b)
		{
			cout<<"IMPOSSIBLE"<<endl;
			return 0;
		}
		if (side == "LEFT")
		{
			L[a].push_back(b);
		}
		else
		{
			R[a].push_back(b);
		}
	}
	int r = solve(0, n-1);
	if (r == -1)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		show(0);
		cout<<endl;
	}
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <memory.h>
#include <stack>
#include <fstream>
#include <cstdio>
#include <unordered_map>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

/*
*/

int n;
vector<vector<int> > L;
vector<vector<int> > R;
vector<vector<int> > tr;

int solve(int i, int end)
{
	int extendL = i;
	for (int j = 0; j < L[i].size(); j++)
	{
		extendL = max(extendL, L[i][j]);
		if (L[i][j] < i) return -1;
	}
	int startR = i;
	if (extendL > i)
	{
		tr[i][0] = i+1;
		startR = solve(i+1, extendL);
		if (startR == -1) return -1;
	}
	int extendR = max(end, startR);
	for (int j = 0; j < R[i].size(); j++)
	{
		extendR = max(extendR, R[i][j]);
		if (R[i][j] <= startR) return -1;
	}
	int fin = startR;
	startR++;
	if (extendR >= startR)
	{
		tr[i][1] = startR;
		fin = solve(startR, extendR);
		if (fin == -1) return -1;
	}
	if (fin < end) return -1;
	return fin;
}

void show(int i)
{
	if (i == -1) return;
	show(tr[i][0]);
	cout<<" "<<i+1;
	show(tr[i][1]);
}
int main()
{
	int c;
	cin>>n>>c;
	tr = vector<vector<int> > (n, vector<int> (2, -1));
	L = vector<vector<int> > (n);
	R = vector<vector<int> > (n);
	for (int i = 0; i < c; i++)
	{
		int a, b;
		string side;
		cin>>a>>b>>side;
		a--;
		b--;
		if (a >= b)
		{
			cout<<"IMPOSSIBLE"<<endl;
			return 0;
		}
		if (side == "LEFT")
		{
			L[a].push_back(b);
		}
		else
		{
			R[a].push_back(b);
		}
	}
	int r = solve(0, n-1);
	if (r == -1)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		show(0);
		cout<<endl;
	}
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <memory.h>
#include <stack>
#include <fstream>
#include <cstdio>
#include <unordered_map>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

/*
*/

int n;
vector<vector<int> > L;
vector<vector<int> > R;
vector<vector<int> > tr;

int solve(int i, int end)
{
	int extendL = i;
	for (int j = 0; j < L[i].size(); j++)
	{
		extendL = max(extendL, L[i][j]);
		if (L[i][j] < i) return -1;
	}
	int startR = i;
	if (extendL > i)
	{
		tr[i][0] = i+1;
		startR = solve(i+1, extendL);
		if (startR == -1) return -1;
	}
	int extendR = max(end, startR);
	for (int j = 0; j < R[i].size(); j++)
	{
		extendR = max(extendR, R[i][j]);
		if (R[i][j] < startR) return -1;
	}
	int fin = startR;
	startR++;
	if (extendR >= startR)
	{
		tr[i][1] = startR;
		fin = solve(startR, extendR);
		if (fin == -1) return -1;
	}
	return fin;
}

void show(int i)
{
	if (i == -1) return;
	show(tr[i][0]);
	cout<<" "<<i+1;
	show(tr[i][1]);
}
int main()
{
	int c;
	cin>>n>>c;
	tr = vector<vector<int> > (n, vector<int> (2, -1));
	L = vector<vector<int> > (n);
	R = vector<vector<int> > (n);
	for (int i = 0; i < c; i++)
	{
		int a, b;
		string side;
		cin>>a>>b>>side;
		a--;
		b--;
		if (side == "LEFT")
		{
			L[a].push_back(b);
		}
		else
		{
			R[a].push_back(b);
		}
	}
	int r = solve(0, n-1);
	if (r == -1)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		show(0);
		cout<<endl;
	}
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <memory.h>
#include <stack>
#include <fstream>
#include <cstdio>
#include <unordered_map>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

/*
*/

int n;
vector<vector<int> > L;
vector<vector<int> > R;
vector<vector<int> > tr;

int solve(int i, int end)
{
	int extendL = i;
	for (int j = 0; j < L[i].size(); j++)
	{
		extendL = max(extendL, L[i][j]);
		if (L[i][j] < i) return -1;
	}
	int startR = i;
	if (extendL > i)
	{
		tr[i][0] = i+1;
		startR = solve(i+1, extendL);
		if (startR == -1) return -1;
	}
	int extendR = max(end, startR);
	for (int j = 0; j < R[i].size(); j++)
	{
		extendR = max(extendR, R[i][j]);
		if (R[i][j] < startR) return -1;
	}
	int fin = startR;
	startR++;
	if (extendR >= startR)
	{
		tr[i][1] = startR;
		fin = solve(startR, extendR);
		if (fin == -1) return -1;
	}
	if (fin < end) return -1;
	return fin;
}

void show(int i)
{
	if (i == -1) return;
	show(tr[i][0]);
	cout<<" "<<i+1;
	show(tr[i][1]);
}
int main()
{
	int c;
	cin>>n>>c;
	tr = vector<vector<int> > (n, vector<int> (2, -1));
	L = vector<vector<int> > (n);
	R = vector<vector<int> > (n);
	for (int i = 0; i < c; i++)
	{
		int a, b;
		string side;
		cin>>a>>b>>side;
		a--;
		b--;
		if (a >= b)
		{
			cout<<"IMPOSSIBLE"<<endl;
			return 0;
		}
		if (side == "LEFT")
		{
			L[a].push_back(b);
		}
		else
		{
			R[a].push_back(b);
		}
	}
	int r = solve(0, n-1);
	if (r == -1)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		show(0);
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
constexpr int MAXN = 1000000;

vector<int> gr[MAXN][2];
vector<int> ans;

int Dfs(int from, int maxv) {
    int nxt = from + 1;
    if (!empty(gr[from][0])) {
        auto [mn, mx] = minmax_element(all(gr[from][0]));
        if (nxt > *mn) {
            return INF;
        }
        nxt = Dfs(nxt, *mx);
    }
    ans.push_back(from + 1);
    if (!empty(gr[from][1])) {
        auto [mn, mx] = minmax_element(all(gr[from][1]));
        if (nxt > *mn) {
            return INF;
        }
        nxt = Dfs(nxt, max(maxv, *mx));
    } else if (nxt <= maxv) {
        nxt = Dfs(nxt, maxv);
    }
    return nxt;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    string s;
    loop(m) {
        int a, b;
        cin >> a >> b >> s;
        if (a >= b) {
            RET("IMPOSSIBLE");
        }
        --a; --b;
        gr[a][s[0] == 'R'].push_back(b);
    }
    if (Dfs(0, n - 1) == INF) {
        RET("IMPOSSIBLE");
    }
    outarr(all(ans));

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
constexpr int MAXN = 1000000;

vector<int> gr[MAXN][2];
vector<int> ans;

int Dfs(int from, int maxv) {
    int nxt = from + 1;
    if (!empty(gr[from][0])) {
        auto [mn, mx] = minmax_element(all(gr[from][0]));
        if (nxt > *mn) {
            return INF;
        }
        nxt = Dfs(nxt, *mx);
    }
    ans.push_back(from + 1);
    if (!empty(gr[from][1])) {
        auto [mn, mx] = minmax_element(all(gr[from][1]));
        if (nxt > *mn) {
            return INF;
        }
        nxt = Dfs(nxt, *mx);
    } else if (nxt <= maxv) {
        nxt = Dfs(nxt, maxv);
    }
    return nxt;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    string s;
    loop(m) {
        int a, b;
        cin >> a >> b >> s;
        if (a >= b) {
            RET("IMPOSSIBLE");
        }
        --a; --b;
        gr[a][s[0] == 'R'].push_back(b);
    }
    if (Dfs(0, n) == INF) {
        RET("IMPOSSIBLE");
    }
    outarr(all(ans));

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
constexpr int MAXN = 1000000;

vector<int> gr[MAXN][2];
vector<int> ans;

int Dfs(int from, int maxv) {
    int nxt = from + 1;
    if (!empty(gr[from][0])) {
        auto [mn, mx] = minmax_element(all(gr[from][0]));
        if (nxt > *mn) {
            return INF;
        }
        nxt = Dfs(nxt, *mx);
    }
    ans.push_back(from + 1);
    if (!empty(gr[from][1])) {
        auto [mn, mx] = minmax_element(all(gr[from][1]));
        if (nxt > *mn) {
            return INF;
        }
        nxt = Dfs(nxt, max(maxv, *mx));
    } else if (nxt <= maxv) {
        nxt = Dfs(nxt, maxv);
    }
    return nxt;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    string s;
    loop(m) {
        int a, b;
        cin >> a >> b >> s;
        if (a >= b) {
            RET("IMPOSSIBLE");
        }
        --a; --b;
        gr[a][s[0] == 'R'].push_back(b);
    }
    if (Dfs(0, n) == INF) {
        RET("IMPOSSIBLE");
    }
    outarr(all(ans));

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> PII;
const int N = 1e6+7;
PII tr[4*N];
int lz[4*N];

///2. Push lazy down and merge lazy
void propagate(int u, int st, int en) {
    tr[u].first += lz[u];
    if (st!=en) {
        lz[2*u] += lz[u];
        lz[2*u+1] += lz[u];
    }
    lz[u] = 0;
}

void build(int u, int st, int en) {
    if (st==en) {
        tr[u] = {0, st};
        lz[u] = 0;
    }
    else {
        int mid = (st+en)/2;
        build(2*u, st, mid);
        build(2*u+1, mid+1, en);
        tr[u] = min(tr[2*u], tr[2*u+1]);
        lz[u] = 0;              ///3. Initialize
    }
}

void update(int u, int st, int en, int l, int r, int x) {
    propagate(u, st, en);
    if (r<st || en<l)  return;
    else if (l<=st && en<=r) {
        lz[u] += x;             ///4. Merge lazy
        propagate(u, st, en);
    }
    else {
        int mid = (st+en)/2;
        update(2*u, st, mid, l, r, x);
        update(2*u+1, mid+1, en, l, r, x);
        tr[u] = min(tr[2*u], tr[2*u+1]);
    }
}

PII query(int u, int st, int en, int l, int r) {
    propagate(u, st, en);
    if (r<st || en<l)  return {1e9, 1e9};        /// 5. Proper null value
    else if (l<=st && en<=r)    return tr[u];
    else {
        int mid = (st+en)/2;
        return min(query(2*u, st, mid, l, r), query(2*u+1, mid+1, en, l, r));
    }
}

int a[N], b[N];
char type[N];
vector<int> v[N];
int n, q;
vector<int> ans;

bool solve(int l, int r) {
    if (l > r)  return true;

    int ll=l, rr=r+1;
    for (int id: v[l]) {
        update(1,1,n,a[id],b[id],-1);

        if (type[id] == 'L')     ll = max(ll, b[id]);
        else                    rr = min(rr, b[id]);
    }
    if (ll >= rr)   return false;

    PII nd = query(1,1,n,ll,rr-1);
//    cout<<ll<<" "<<rr<<" "<<nd.first<<" "<<nd.second<<endl;
    if (nd.first > 0) return false;
    int mid = nd.second;
    if (mid < ll || mid >= rr)  return false;
    if (!solve(l+1, mid))   return false;
    ans.push_back(l);
    if (!solve(mid+1,r))    return false;
    return true;
}

int main() {
    cin>>n>>q;

    build(1, 1, n);

    for (int i=1; i<=q; i++)   {
        cin>>a[i]>>b[i];
        if (a[i] >= b[i]) {
            cout<<"IMPOSSIBLE"<<endl;
            return 0;
        }
        update(1,1,n,a[i],b[i]-1,1);
//        cout<<"Add "<<a[i]<<" to "<<b[i]-1<<endl;
        v[a[i]].push_back(i);
        string s;
        cin>>s;
        type[i] = s[0];
    }

    if (!solve(1, n)){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }

    for (int x: ans)    cout<<x<<" ";
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> PII;
const int N = 1e6+7;
PII tr[4*N];
int lz[4*N];

///2. Push lazy down and merge lazy
void propagate(int u, int st, int en) {
    tr[u].first += lz[u];
    if (st!=en) {
        lz[2*u] += lz[u];
        lz[2*u+1] += lz[u];
    }
    lz[u] = 0;
}

void build(int u, int st, int en) {
    if (st==en) {
        tr[u] = {0, st};
        lz[u] = 0;
    }
    else {
        int mid = (st+en)/2;
        build(2*u, st, mid);
        build(2*u+1, mid+1, en);
        tr[u] = min(tr[2*u], tr[2*u+1]);
        lz[u] = 0;              ///3. Initialize
    }
}

void update(int u, int st, int en, int l, int r, int x) {
    propagate(u, st, en);
    if (r<st || en<l)  return;
    else if (l<=st && en<=r) {
        lz[u] += x;             ///4. Merge lazy
        propagate(u, st, en);
    }
    else {
        int mid = (st+en)/2;
        update(2*u, st, mid, l, r, x);
        update(2*u+1, mid+1, en, l, r, x);
        tr[u] = min(tr[2*u], tr[2*u+1]);
    }
}

PII query(int u, int st, int en, int l, int r) {
    propagate(u, st, en);
    if (r<st || en<l)  return {1e9, 1e9};        /// 5. Proper null value
    else if (l<=st && en<=r)    return tr[u];
    else {
        int mid = (st+en)/2;
        return min(query(2*u, st, mid, l, r), query(2*u+1, mid+1, en, l, r));
    }
}

int a[N], b[N];
char type[N];
vector<int> v[N];
int n, q;
vector<int> ans;

bool solve(int l, int r) {
    cout<<"-----> "<<l<<" "<<r<<endl;
    if (l > r)  return true;

    int ll=l, rr=r+1;
    for (int id: v[l]) {
        update(1,1,n,a[id],b[id],-1);

        if (type[id] == 'L')     ll = max(ll, b[id]);
        else                    rr = min(rr, b[id]);
    }
    if (ll >= rr)   return false;

    PII nd = query(1,1,n,ll,rr-1);
//    cout<<ll<<" "<<rr<<" "<<nd.first<<" "<<nd.second<<endl;
    if (nd.first > 0) return false;
    int mid = nd.second;
    if (mid < ll || mid >= rr)  return false;
    if (!solve(l+1, mid))   return false;
    ans.push_back(l);
    if (!solve(mid+1,r))    return false;
    return true;
}

int main() {
    cin>>n>>q;

    build(1, 1, n);

    for (int i=1; i<=q; i++)   {
        cin>>a[i]>>b[i];
        if (a[i] >= b[i]) {
            cout<<"IMPOSSIBLE"<<endl;
            return 0;
        }
        update(1,1,n,a[i],b[i]-1,1);
//        cout<<"Add "<<a[i]<<" to "<<b[i]-1<<endl;
        v[a[i]].push_back(i);
        string s;
        cin>>s;
        type[i] = s[0];
    }

    if (!solve(1, n)){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }

    for (int x: ans)    cout<<x<<" ";
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> PII;
const int N = 1e6+7;
PII tr[4*N];
int lz[4*N];

///2. Push lazy down and merge lazy
void propagate(int u, int st, int en) {
    tr[u].first += lz[u];
    if (st!=en) {
        lz[2*u] += lz[u];
        lz[2*u+1] += lz[u];
    }
    lz[u] = 0;
}

void build(int u, int st, int en) {
    if (st==en) {
        tr[u] = {0, st};
        lz[u] = 0;
    }
    else {
        int mid = (st+en)/2;
        build(2*u, st, mid);
        build(2*u+1, mid+1, en);
        tr[u] = min(tr[2*u], tr[2*u+1]);
        lz[u] = 0;              ///3. Initialize
    }
}

void update(int u, int st, int en, int l, int r, int x) {
    propagate(u, st, en);
    if (r<st || en<l)  return;
    else if (l<=st && en<=r) {
        lz[u] += x;             ///4. Merge lazy
        propagate(u, st, en);
    }
    else {
        int mid = (st+en)/2;
        update(2*u, st, mid, l, r, x);
        update(2*u+1, mid+1, en, l, r, x);
        tr[u] = min(tr[2*u], tr[2*u+1]);
    }
}

PII query(int u, int st, int en, int l, int r) {
    propagate(u, st, en);
    if (r<st || en<l)  return {1e9, 1e9};        /// 5. Proper null value
    else if (l<=st && en<=r)    return tr[u];
    else {
        int mid = (st+en)/2;
        return min(query(2*u, st, mid, l, r), query(2*u+1, mid+1, en, l, r));
    }
}

int a[N], b[N];
char type[N];
vector<int> v[N];
int n, q;
vector<int> ans;

bool solve(int l, int r) {
//    cout<<"-----> "<<l<<" "<<r<<endl;
    if (l > r)  return true;

    int ll=l, rr=r+1;
    for (int id: v[l]) {
        update(1,1,n,a[id],b[id],-1);

        if (type[id] == 'L')     ll = max(ll, b[id]);
        else                    rr = min(rr, b[id]);
    }
    if (ll >= rr)   return false;

    PII nd = query(1,1,n,ll,rr-1);
//    cout<<ll<<" "<<rr<<" "<<nd.first<<" "<<nd.second<<endl;
    if (nd.first > 0) return false;
    int mid = nd.second;
    if (!solve(l+1, mid))   return false;
    ans.push_back(l);
    if (!solve(mid+1,r))    return false;
    return true;
}

int main() {
    cin>>n>>q;

    build(1, 1, n);

    for (int i=1; i<=q; i++)   {
        cin>>a[i]>>b[i];
        if (a[i] >= b[i]) {
            cout<<"IMPOSSIBLE"<<endl;
            return 0;
        }
        update(1,1,n,a[i],b[i]-1,1);
//        cout<<"Add "<<a[i]<<" to "<<b[i]-1<<endl;
        v[a[i]].push_back(i);
        string s;
        cin>>s;
        type[i] = s[0];
    }

    if (!solve(1, n)){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }

    for (int x: ans)    cout<<x<<" ";
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> PII;
const int N = 1e6+7;
PII tr[4*N];
int lz[4*N];

///2. Push lazy down and merge lazy
void propagate(int u, int st, int en) {
    tr[u].first += lz[u];
    if (st!=en) {
        lz[2*u] += lz[u];
        lz[2*u+1] += lz[u];
    }
    lz[u] = 0;
}

void build(int u, int st, int en) {
    if (st==en) {
        tr[u] = {0, st};
        lz[u] = 0;
    }
    else {
        int mid = (st+en)/2;
        build(2*u, st, mid);
        build(2*u+1, mid+1, en);
        tr[u] = min(tr[2*u], tr[2*u+1]);
        lz[u] = 0;              ///3. Initialize
    }
}

void update(int u, int st, int en, int l, int r, int x) {
    propagate(u, st, en);
    if (r<st || en<l)  return;
    else if (l<=st && en<=r) {
        lz[u] += x;             ///4. Merge lazy
        propagate(u, st, en);
    }
    else {
        int mid = (st+en)/2;
        update(2*u, st, mid, l, r, x);
        update(2*u+1, mid+1, en, l, r, x);
        tr[u] = min(tr[2*u], tr[2*u+1]);
    }
}

PII query(int u, int st, int en, int l, int r) {
    propagate(u, st, en);
    if (r<st || en<l)  return {1e9, 1e9};        /// 5. Proper null value
    else if (l<=st && en<=r)    return tr[u];
    else {
        int mid = (st+en)/2;
        return min(query(2*u, st, mid, l, r), query(2*u+1, mid+1, en, l, r));
    }
}

int a[N], b[N];
char type[N];
vector<int> v[N];
int n, q;
vector<int> ans;

bool solve(int l, int r) {
    if (l > r)  return true;

    int ll=l, rr=r+1;
    for (int id: v[l]) {
        update(1,1,n,a[id],b[id]-1,-1);

        if (type[id] == 'L')     ll = max(ll, b[id]);
        else                    rr = min(rr, b[id]);
    }
    if (ll >= rr)   return false;

    PII nd = query(1,1,n,ll,rr-1);
    if (nd.first > 0) return false;
    int mid = nd.second;
    if (!solve(l+1, mid))   return false;
    ans.push_back(l);
    if (!solve(mid+1,r))    return false;
    return true;
}

int main() {
    cin>>n>>q;

    build(1, 1, n);

    for (int i=1; i<=q; i++)   {
        cin>>a[i]>>b[i];
        if (a[i] >= b[i]) {
            cout<<"IMPOSSIBLE"<<endl;
            return 0;
        }
        update(1,1,n,a[i],b[i]-1,1);
        v[a[i]].push_back(i);
        string s;
        cin>>s;
        type[i] = s[0];
    }

    if (!solve(1, n)){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }

    for (int x: ans)    cout<<x<<" ";
}


#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
#define pb push_back
using std::cin;
using std::cout;

typedef unsigned long long u64;
typedef double db;
typedef long long ll;
typedef unsigned u32;

const int N = 1001000;

int n, c;
std::vector<int> le[N], ri[N];
int maxl[N], minr[N];
int max[N];
inline void no() { puts("IMPOSSIBLE"), exit(0); }
inline void up(int & x, int y) { if(x < y) x = y; }
inline void down(int & x, int y) { if(x > y) x = y; }
const int L=1<<20;
int seg[L<<1];
inline void upt(int pos,int v){
	for(seg[pos+=L]=v;pos>>=1;) seg[pos]=std::max(seg[pos<<1],seg[pos<<1|1]);
}
inline int ask(int l,int r){
	int res=0;
	l+=L-1,r+=L+1;
	for(;l+1!=r;l>>=1,r>>=1){
		if((l&1)==0)up(res,seg[l^1]);
		if((r&1)==1)up(res,seg[r^1]);
	}
	return res;
}
std::vector<int>res;
inline void solve(int l,int r){
	if(l>r)return;
	if(le[l].empty()) return res.pb(l),solve(l+1,r);
	if(ri[l].empty()) return solve(l+1,r),res.pb(l);
	int pos=ask(l+1,maxl[l]);
	if(pos>=minr[l])no();
	solve(l+1,pos);
	res.pb(l);
	solve(pos+1,r);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> c;
	rep(i, 1, n) minr[i] = n, max[i] = i;
	rep(i, 1, c) {
		int a, b;
		char buf[10];
		cin >> a >> b >> buf;
		if(b < a) no();
		up(max[a], b);
		if(*buf == 'L') {
			up(maxl[a], b);
			le[a].pb(b);
		} else {
			down(minr[a], b);
			ri[a].pb(b);
		}
	}
	rep(i,1,n)if(maxl[i]>=minr[i])no();
	for(int i = n;i >= 1;--i) {
		up(max[i],ask(i,max[i]));
		upt(i,max[i]);
	}
	solve(1,n);
	for(int x:res)cout<<x<<' ';
}


#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
#define pb push_back
using std::cin;
using std::cout;

typedef unsigned long long u64;
typedef double db;
typedef long long ll;
typedef unsigned u32;

const int N = 1001000;

int n, c;
std::vector<int> le[N], ri[N];
int max[N], min[N];
int vis[N];
inline void no() { puts("IMPOSSIBLE"), exit(0); }
inline void up(int & x, int y) {
	if(x < y) x = y;
}
inline int dfs(int x) {
	if(vis[x]) no();
	if(~max[x]) return max[x];
	max[x] = x, vis[x] = 1;
	for(int u : le[x]) up(max[x], dfs(u));
	for(int u : ri[x]) up(max[x], dfs(u));
	vis[x] = 0;
	return max[x];
}
std::vector<int>res;
inline void get(int x, int R) {
	if(x > R) return;
	int mx = x;
	for(int u : le[x]) up(mx, max[u]);
	for(int u : ri[x]) if(u <= mx) no();
	get(x + 1, mx);
	res.pb(x);
	get(mx + 1, R);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> c;
	rep(i, 1, c) {
		int a, b;
		char buf[10];
		cin >> a >> b >> buf;
		if(b < a) no();
		if(*buf == 'L') {
			le[a].pb(b);
		} else {
			ri[a].pb(b);
		}
	}
	rep(i, 1, n) max[i] = min[i] = -1;
	rep(i, 1, n) dfs(i);
	get(1, n);
	for(int x:res)cout<<x<<' ';
}


#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
#define pb push_back
using std::cin;
using std::cout;

typedef unsigned long long u64;
typedef double db;
typedef long long ll;
typedef unsigned u32;

const int N = 1001000;

int n, c;
std::vector<int> le[N], ri[N];
int maxl[N], minr[N];
int max[N];
inline void no() { puts("IMPOSSIBLE"), exit(0); }
inline void up(int & x, int y) { if(x < y) x = y; }
inline void down(int & x, int y) { if(x > y) x = y; }
const int L=1<<20;
int seg[L<<1];
inline void upt(int pos,int v){
	for(seg[pos+=L]=v;pos>>=1;) seg[pos]=std::max(seg[pos<<1],seg[pos<<1|1]);
}
inline int ask(int l,int r){
	int res=0;
	l+=L-1,r+=L+1;
	for(;l+1!=r;l>>=1,r>>=1){
		if((l&1)==0)up(res,seg[l^1]);
		if((r&1)==1)up(res,seg[r^1]);
	}
	return res;
}
std::vector<int>res;
inline void solve(int l,int r){
	if(l>r)return;
	if(le[l].empty()) return res.pb(l),solve(l+1,r);
	if(ri[l].empty()) return solve(l+1,r),res.pb(l);
	int pos=ask(l+1,maxl[l]);
	if(pos>=minr[l])no();
	solve(l+1,pos);
	res.pb(l);
	solve(pos+1,r);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> c;
	rep(i, 1, n) minr[i] = n+1, max[i] = i;
	rep(i, 1, c) {
		int a, b;
		char buf[10];
		cin >> a >> b >> buf;
		if(b <= a) no();
		up(max[a], b);
		if(*buf == 'L') {
			up(maxl[a], b);
			le[a].pb(b);
		} else {
			down(minr[a], b);
			ri[a].pb(b);
		}
	}
	rep(i,1,n)if(maxl[i]>=minr[i])no();
	for(int i = n;i >= 1;--i) {
		up(max[i],ask(i,max[i]));
		upt(i,max[i]);
	}
	solve(1,n);
	for(int x:res)cout<<x<<' ';
}


#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
#define pb push_back
using std::cin;
using std::cout;

typedef unsigned long long u64;
typedef double db;
typedef long long ll;
typedef unsigned u32;

const int N = 1001000;

int n, c;
std::vector<int> le[N], ri[N];
int maxl[N], minr[N];
int max[N];
inline void no() { puts("IMPOSSIBLE"), exit(0); }
inline void up(int & x, int y) { if(x < y) x = y; }
inline void down(int & x, int y) { if(x > y) x = y; }
const int L=1<<20;
int seg[L<<1];
inline void upt(int pos,int v){
	for(seg[pos+=L]=v;pos>>=1;) seg[pos]=std::max(seg[pos<<1],seg[pos<<1|1]);
}
inline int ask(int l,int r){
	int res=0;
	l+=L-1,r+=L+1;
	for(;l+1!=r;l>>=1,r>>=1){
		if((l&1)==0)up(res,seg[l^1]);
		if((r&1)==1)up(res,seg[r^1]);
	}
	return res;
}
std::vector<int>res;
inline void solve(int l,int r){
	if(l>r)return;
	if(le[l].empty()) return res.pb(l),solve(l+1,r);
	if(ri[l].empty()) return solve(l+1,r),res.pb(l);
	int pos=ask(l+1,maxl[l]);
	if(pos>=minr[l])no();
	solve(l+1,pos);
	res.pb(l);
	solve(pos+1,r);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> c;
	rep(i, 1, n) minr[i] = n, max[i] = i;
	rep(i, 1, c) {
		int a, b;
		char buf[10];
		cin >> a >> b >> buf;
		if(b <= a) no();
		up(max[a], b);
		if(*buf == 'L') {
			up(maxl[a], b);
			le[a].pb(b);
		} else {
			down(minr[a], b);
			ri[a].pb(b);
		}
	}
	rep(i,1,n)if(maxl[i]>=minr[i])no();
	for(int i = n;i >= 1;--i) {
		up(max[i],ask(i,max[i]));
		upt(i,max[i]);
	}
	solve(1,n);
	for(int x:res)cout<<x<<' ';
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
#include <bitset>
#include <cctype>
#include <list>
#include <assert.h>
#include <random>
#include <unordered_map>
typedef long long ll;
#define MAX 1000005
using namespace std;
#define INF 2147483647
#define infL (1LL<<60)
#define inf (1<<30)
#define MOD 1000000007
#define EPS 1e-9
#define Gr 9.8
#define PI acos(-1)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define lch (rt<<1)
#define rch (rt<<1|1)
bool debug = 1;
int n,m,k;
int dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};
ll ln, lk, lm;

char s[10];
vector<int> v[MAX][2], ans;
int cnt;
bool dfs(int x) {
    int id = ++cnt;
    if (!v[id][0].empty()) {
        sort(v[id][0].begin(), v[id][0].end());
        if (v[id][0][0] <= cnt || !dfs(v[id][0].back())) return 0;
    }
    ans.push_back(id);
    if (!v[id][1].empty()) {
        sort(v[id][1].begin(), v[id][1].end());
        if (v[id][1][0] <= cnt || !dfs(max(v[id][1].back(), x))) return 0;
    } else {
        if (cnt < x && !dfs(x)) return 0;
    }
    return 1;
}
int main() {
    int c,x,y;
    scanf("%d%d",  &n, &c);
    REP(i,c) {
        scanf("%d%d%s",&x,&y,s);
        v[x][s[0]=='R'].push_back(y);
    }
    if (dfs(n)) {
        for(int c:ans) printf("%d ", c);
    } else puts("IMPOSSIBLE");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1000000;
const int MAXC = 100000;

vector<int> l[MAXN], r[MAXN];

int x[MAXN], y[MAXN];

vector<int> s;

int dfs(int v, int mx)
{
    if (mx == v)
    {
        x[v] = -1;
        y[v] = -1;
        return v;
    }
    if (l[v].empty())
    {
        x[v] = -1;
        y[v] = v + 1;
        return dfs(v + 1, mx);
    }
    else
    {
        x[v] = v + 1;
        int lst = dfs(v + 1, *l[v].rbegin());
        if (!r[v].empty())
        {
            y[v] = lst + 1;
            if (lst >= *r[v].begin())
            {
                cout << "IMPOSSIBLE\n";
                exit(0);
            }
            return dfs(lst + 1, max(mx, *r[v].rbegin()));
        }
        else
        {
            if (lst + 1 <= mx)
            {
                y[v] = lst + 1;
                return dfs(lst + 1, mx);
            }
            return lst;
        }
    }
}

void in_order(int v)
{
    if (x[v] != -1)
        in_order(x[v]);
    s.push_back(v);
    if (y[v] != -1)
        in_order(y[v]);
}

int main()
{
    int n, c;
    cin >> n >> c;
    for (int i = 0; i < c; ++i)
    {
        int a, b;
        string d;
        cin >> a >> b >> d;
        --a, --b;
        if (d == "LEFT")
            l[a].push_back(b);
        else
            r[a].push_back(b);
    }
    for (int i = 0; i < n; ++i)
    {
        sort(l[i].begin(), l[i].end());
        sort(r[i].begin(), r[i].end());
    }
    dfs(0, n - 1);
    in_order(0);
    for (int i = 0; i < n; ++i)
        cout << s[i] + 1 << ' ';
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100;
const int MAXC = 50;

int lmn[MAXN], lmx[MAXN], lsz[MAXN];
int rmn[MAXN], rmx[MAXN], rsz[MAXN];

int l[MAXN], r[MAXN];

int dfs(int v, int x)
{
    if (lsz[v] == 0)
    {
        l[v] = -1;
        if (rsz[v] == 0)
        {
            if (v == x)
            {
                r[v] = -1;
                return v;
            }
            else
            {
                r[v] = v + 1;
                return dfs(v + 1, x);
            }
        }
        else
        {
            r[v] = v + 1;
            return dfs(v + 1, max(x, rmx[v]));
        }
    }
    else
    {
        l[v] = v + 1;
        int y = dfs(v + 1, lmx[v]);
        if (rsz[v] > 0)
        {
            if (y >= rmn[v])
            {
                cout << "IMPOSSIBLE\n";
                exit(0);
            }
            r[v] = y + 1;
            return dfs(y + 1, max(x, rmx[v]));
        }
        else
        {
            if (y + 1 <= x)
            {
                r[v] = y + 1;
                return dfs(y + 1, x);
            }
            r[v] = -1;
            return y;
        }
    }
}

void in_order(int v)
{
    if (l[v] != -1)
        in_order(l[v]);
    cout << v + 1 << ' ';
    if (r[v] != -1)
        in_order(r[v]);
}

int main()
{
    int n, c;
    cin >> n >> c;
    for (int i = 0; i < n; ++i)
    {
        lmn[i] = rmn[i] = INT_MAX;
        lmx[i] = rmx[i] = INT_MIN;
        lsz[i] = rsz[i] = 0;
    }
    for (int i = 0; i < c; ++i)
    {
        int a, b;
        string d;
        cin >> a >> b >> d;
        --a, --b;
        if (d == "LEFT")
        {
            lsz[a]++;
            lmn[a] = min(lmn[a], b);
            lmx[a] = max(lmx[a], b);
        }
        else
        {
            rsz[a]++;
            rmn[a] = min(rmn[a], b);
            rmx[a] = max(rmx[a], b);
        }
    }
    for (int i = 0; i < n; ++i)
    {
        if (lmx[i] > rmn[i])
        {
            cout << "IMPOSSIBLE\n";
            exit(0);
        }
    }
    dfs(0, n - 1);
    in_order(0);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1000000;
const int MAXC = 100000;

int lmn[MAXN], lmx[MAXN], lsz[MAXN];
int rmn[MAXN], rmx[MAXN], rsz[MAXN];

int l[MAXN], r[MAXN];

int dfs(int v, int x)
{
    if (lsz[v] == 0)
    {
        l[v] = -1;
        if (rsz[v] == 0)
        {
            if (v == x)
            {
                r[v] = -1;
                return v;
            }
            else
            {
                r[v] = v + 1;
                return dfs(v + 1, x);
            }
        }
        else
        {
            r[v] = v + 1;
            return dfs(v + 1, max(x, rmx[v]));
        }
    }
    else
    {
        l[v] = v + 1;
        int y = dfs(v + 1, lmx[v]);
        if (rsz[v] > 0)
        {
            if (y >= rmn[v])
            {
                cout << "IMPOSSIBLE\n";
                exit(0);
            }
            r[v] = y + 1;
            return dfs(y + 1, max(x, rmx[v]));
        }
        else
        {
            if (y + 1 <= x)
            {
                r[v] = y + 1;
                return dfs(y + 1, x);
            }
            r[v] = -1;
            return y;
        }
    }
}

void in_order(int v)
{
    if (l[v] != -1)
        in_order(l[v]);
    cout << v + 1 << ' ';
    if (r[v] != -1)
        in_order(r[v]);
}

int main()
{
    int n, c;
    cin >> n >> c;
    for (int i = 0; i < n; ++i)
    {
        lmn[i] = rmn[i] = INT_MAX;
        lmx[i] = rmx[i] = INT_MIN;
        lsz[i] = rsz[i] = 0;
    }
    for (int i = 0; i < c; ++i)
    {
        int a, b;
        string d;
        cin >> a >> b >> d;
        --a, --b;
        if (d == "LEFT")
        {
            lsz[a]++;
            lmn[a] = min(lmn[a], b);
            lmx[a] = max(lmx[a], b);
        }
        else
        {
            rsz[a]++;
            rmn[a] = min(rmn[a], b);
            rmx[a] = max(rmx[a], b);
        }
    }
    for (int i = 0; i < n; ++i)
    {
        if (lmx[i] >= rmn[i] || lmn[i] <= i || rmn[i] <= i)
        {
            cout << "IMPOSSIBLE\n";
            exit(0);
        }
    }
    dfs(0, n - 1);
    in_order(0);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1000000;
const int MAXC = 100000;

vector<int> l[MAXN], r[MAXN];

int x[MAXN], y[MAXN];

vector<int> s;

int dfs(int v, int mx)
{
    if (l[v].empty())
    {
        x[v] = -1;
        if (r[v].empty())
        {
            if (v == mx)
            {
                x[v] = y[v] = -1;
                return v;
            }
            else
            {
                y[v] = v + 1;
                return dfs(v + 1, mx);
            }
        }
        else
        {
            y[v] = v + 1;
            return dfs(v + 1, max(mx, *r[v].rbegin()));
        }
    }
    else
    {
        x[v] = v + 1;
        int lst = dfs(v + 1, *l[v].rbegin());
        if (!r[v].empty())
        {
            y[v] = lst + 1;
            if (lst >= *r[v].begin())
            {
                cout << "IMPOSSIBLE\n";
                exit(0);
            }
            return dfs(lst + 1, max(mx, *r[v].rbegin()));
        }
        else
        {
            if (lst + 1 <= mx)
            {
                y[v] = lst + 1;
                return dfs(lst + 1, mx);
            }
            return lst;
        }
    }
}

void in_order(int v)
{
    if (x[v] != -1)
        in_order(x[v]);
    s.push_back(v);
    if (y[v] != -1)
        in_order(y[v]);
}

int main()
{
    int n, c;
    cin >> n >> c;
    for (int i = 0; i < c; ++i)
    {
        int a, b;
        string d;
        cin >> a >> b >> d;
        --a, --b;
        if (d == "LEFT")
            l[a].push_back(b);
        else
            r[a].push_back(b);
    }
    for (int i = 0; i < n; ++i)
    {
        sort(l[i].begin(), l[i].end());
        sort(r[i].begin(), r[i].end());
    }
    dfs(0, n - 1);
    in_order(0);
    for (int i = 0; i < n; ++i)
        cout << s[i] + 1 << ' ';
    cout << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1000000;
const int MAXC = 100000;

int lmn[MAXN], lmx[MAXN], lsz[MAXN];
int rmn[MAXN], rmx[MAXN], rsz[MAXN];

int l[MAXN], r[MAXN];

int dfs(int v, int x)
{
    if (lsz[v] == 0)
    {
        l[v] = -1;
        if (rsz[v] == 0)
        {
            if (v == x)
            {
                l[v] = r[v] = -1;
                return v;
            }
            else
            {
                r[v] = v + 1;
                return dfs(v + 1, x);
            }
        }
        else
        {
            r[v] = v + 1;
            return dfs(v + 1, max(x, rmx[v]));
        }
    }
    else
    {
        l[v] = v + 1;
        int y = dfs(v + 1, lmx[v]);
        if (rsz[v] > 0)
        {
            r[v] = y + 1;
            if (y >= rmn[v])
            {
                cout << "IMPOSSIBLE\n";
                exit(0);
            }
            return dfs(y + 1, max(x, rmx[v]));
        }
        else
        {
            if (y + 1 <= x)
            {
                r[v] = y + 1;
                return dfs(y + 1, x);
            }
            return x;
        }
    }
}

void in_order(int v)
{
    if (l[v] != -1)
        in_order(l[v]);
    cout << v + 1 << ' ';
    if (r[v] != -1)
        in_order(r[v]);
}

int main()
{
    int n, c;
    cin >> n >> c;
    for (int i = 0; i < n; ++i)
    {
        lmn[i] = rmn[i] = INT_MAX;
        lmx[i] = rmx[i] = INT_MIN;
        lsz[i] = rsz[i] = 0;
    }
    for (int i = 0; i < c; ++i)
    {
        int a, b;
        string d;
        cin >> a >> b >> d;
        --a, --b;
        if (d == "LEFT")
        {
            lsz[a]++;
            lmn[a] = min(lmn[a], b);
            lmx[a] = max(lmx[a], b);
        }
        else
        {
            rsz[a]++;
            rmn[a] = min(rmn[a], b);
            rmx[a] = max(rmx[a], b);
        }
    }
    dfs(0, n - 1);
    in_order(0);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1000000;
const int MAXC = 100000;

int lmn[MAXN], lmx[MAXN], lsz[MAXN];
int rmn[MAXN], rmx[MAXN], rsz[MAXN];

int l[MAXN], r[MAXN];

int dfs(int v, int x)
{
    if (lsz[v] == 0)
    {
        l[v] = -1;
        if (rsz[v] == 0)
        {
            if (v == x)
            {
                r[v] = -1;
                return v;
            }
            else
            {
                r[v] = v + 1;
                return dfs(v + 1, x);
            }
        }
        else
        {
            r[v] = v + 1;
            return dfs(v + 1, max(x, rmx[v]));
        }
    }
    else
    {
        l[v] = v + 1;
        int y = dfs(v + 1, lmx[v]);
        if (rsz[v] > 0)
        {
            if (y >= rmn[v])
            {
                cout << "IMPOSSIBLE\n";
                exit(0);
            }
            r[v] = y + 1;
            return dfs(y + 1, max(x, rmx[v]));
        }
        else
        {
            if (y + 1 <= x)
            {
                r[v] = y + 1;
                return dfs(y + 1, x);
            }
            r[v] = -1;
            return y;
        }
    }
}

void in_order(int v)
{
    if (l[v] != -1)
        in_order(l[v]);
    cout << v + 1 << ' ';
    if (r[v] != -1)
        in_order(r[v]);
}

int main()
{
    int n, c;
    cin >> n >> c;
    for (int i = 0; i < n; ++i)
    {
        lmn[i] = rmn[i] = INT_MAX;
        lmx[i] = rmx[i] = INT_MIN;
        lsz[i] = rsz[i] = 0;
    }
    for (int i = 0; i < c; ++i)
    {
        int a, b;
        string d;
        cin >> a >> b >> d;
        --a, --b;
        if (d == "LEFT")
        {
            lsz[a]++;
            lmn[a] = min(lmn[a], b);
            lmx[a] = max(lmx[a], b);
        }
        else
        {
            rsz[a]++;
            rmn[a] = min(rmn[a], b);
            rmx[a] = max(rmx[a], b);
        }
    }
    for (int i = 0; i < n; ++i)
    {
        if (lmx[i] >= rmn[i] || lmn[i] <= i)
        {
            cout << "IMPOSSIBLE\n";
            exit(0);
        }
    }
    dfs(0, n - 1);
    in_order(0);
    return 0;
}


#include <bits/stdc++.h>

const int N = 1000005;

void no() {std::cout << "IMPOSSIBLE\n", std::exit(0); }

int n, c, ans[N], tot;
std::vector<int> left[N], right[N];

int min[N << 2], tag[N << 2];
void modify(int L, int R, int v, int o = 1, int l = 1, int r = n) {
	if (L <= l && R >= r) {min[o] += v, tag[o] += v; return; }
	int mid = l + r >> 1;
	if (L <= mid) modify(L, R, v, o << 1, l, mid);
	if (R > mid) modify(L, R, v, o << 1 | 1, mid + 1, r);
	min[o] = std::min(min[o << 1], min[o << 1 | 1]) + tag[o];
}
int find(int L, int R, int o = 1, int l = 1, int r = n) {
	if (min[o]) return -1;
	if (l == r) return l;
	int mid = l + r >> 1;
	if (L <= mid) {
		int p = find(L, R, o << 1, l, mid);
		if (p != -1) return p;
	}
	if (R > mid) {
		int p = find(L, R, o << 1 | 1, mid + 1, r);
		if (p != -1) return p;
	}
	return -1;
}

int find_mid(int l, int r) {
	int min = l, max = r;
	for (int p : left[l]) {
		min = std::max(min, p);
		modify(l, p - 1, -1);
	}
	for (int p : right[l]) {
		max = std::min(max, p - 1);
		modify(l, p - 1, -1);
	}
	if (min > max) no();
	int p = find(min, max);
	if (p == -1) no();
	return p;
}

void solve(int l, int r) {
	if (l > r) return;
	int x = find_mid(l, r);
	solve(l + 1, x);
	ans[++tot] = l;
	solve(x + 1, r);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> c;
	for (int i = 1; i <= c; ++i) {
		int a, b; std::string s;
		std::cin >> a >> b >> s;
		if (b <= a) no();
		if (s[0] == 'L')
			left[a].emplace_back(b);
		else
			right[a].emplace_back(b);
		modify(a, b - 1, 1);
	}
	solve(1, n);
	for (int i = 1; i <= n; ++i)
		std::cout << ans[i] << ' ';
	std::cout << '\n';
	return 0;
}


#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL)

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define maxn 1000005

pii tr[4*maxn] ;
int lazy[4*maxn] ;

void build(int cn, int b, int e)
{
    if(b==e)
    {
        tr[cn] = mp(0,b) ;
        return ;
    }
    int lc = cn*2 , rc=cn*2+1 , m = (b+e)/2 ;
    build(lc,b,m) ; build(rc,m+1,e) ;
    tr[cn] = min(tr[lc],tr[rc]) ;
    return ;
}

void relax(int cn, int b, int e)
{
    tr[cn].xx += lazy[cn] ;
    if(b!=e)
    {
        int lc = cn*2 , rc=cn*2+1 , m = (b+e)/2 ;
        lazy[lc] += lazy[cn] ;
        lazy[rc] += lazy[cn] ;
    }
    lazy[cn] = 0 ;
}

void update(int cn, int b, int e ,int l ,int r, int val)
{
    if( lazy[cn] != 0 ) relax(cn,b,e) ;
    if( b>r || e<l ) return ;
    if( b>=l && e<=r )
    {
        lazy[cn] += val ;
        relax(cn,b,e) ;
        return ;
    }
    int lc = cn*2 , rc=cn*2+1 , m = (b+e)/2 ;
    update(lc,b,m,l,r,val) ; update(rc,m+1,e,l,r,val) ;
    tr[cn] = min(tr[lc],tr[rc]) ;
}

pii query(int cn, int b, int e, int l, int r)
{
    if( lazy[cn] != 0 ) relax(cn,b,e) ;
    if( b>r || e<l ) return mp(INF,0) ;
    if(b>=l && e<=r) return tr[cn] ;

    int lc = cn*2 , rc=cn*2+1 , m = (b+e)/2 ;
    return min( query(lc,b,m,l,r) , query(rc,m+1,e,l,r) ) ;
}

vector<int> myChild[maxn] ;

int L[maxn] , R[maxn] ;
vector <int> Left[maxn] , Right[maxn] ;
vector <int> g[maxn] ;
int n ;

int dfs(int l ,int r)
{
    if(l>=r) return 1 ;
 //   if( Left[u].size() != 0 && Left[u][0] )

    for(int x:Left[l]) update(1,1,n,l+1,x,-1) ;
    for(int x:Right[l]) update(1,1,n,l+1,x,-1) ;

    int cur = l+1 ;

    if( Left[l].size() != 0 )
    {
        pii p = query(1,1,n,Left[l].back()+1,r) ;
        if(p.xx!=0) return 0 ;
        if( Right[l].size()>0 && p.yy > Right[l][0] ) return 0 ;

        L[l] = l+1 ;
        cur = p.yy ;

        int res = dfs( l+1 , p.yy-1 ) ;
        if( res==0 ) return res ;
    }
    R[l] = cur ;
    int res = dfs(cur,r) ;
    if(res==0) return 0 ;

    return 1 ;
}

int ans[maxn] ;

void color( int u , int &cur )
{
    if( L[u] != 0  ) color(L[u],cur) ;
    cur++ ;
    ans[cur] = u ;
    if( R[u] ) color(R[u],cur) ;
}

int main()
{
    int c ;

    scanf("%d %d",&n,&c) ;

    for(int i=1 ; i<=c ; i++)
    {
        int u, v ;
        char s[10] ;
        scanf("%d %d %s",&u,&v,s) ;
        if( s[0]=='L' ) Left[u].pb(v) ;
        else Right[u].pb(v) ;
    }

    build(1,1,n) ;

    for(int i=1 ; i<=n ; i++)
    {
    //    printf("%d %d\n",Left[i].size() , Right[i].size()) ;
        sort( Left[i].begin() , Left[i].end() ) ;
        sort( Right[i].begin() , Right[i].end() ) ;
        for(int v:Left[i])
        {
            if( v<i )
            {
                printf("IMPOSSIBLE\n") ;
                return 0 ;
            }
            update(1,1,n,i+1,v,1) ;
        }
        for(int v:Right[i])
        {
            if( v<i )
            {
                printf("IMPOSSIBLE\n") ;
                return 0 ;
            }
            update(1,1,n,i+1,v,1) ;
        }
    }

    for(int i=1 ; i<=n ; i++)
    {
        int fl = 1 ;
        if( Left[i].size() != 0 && Left[i][0] < i ) fl = 0 ;
        if( Right[i].size() != 0 && Right[i][0] < i ) fl = 0 ;
        if( Left[i].size() && Right[i].size() && Left[i].back() >= Right[i][0] ) fl = 0 ;
        if(fl==0)
        {
            printf("IMPOSSIBLE\n") ;
            return 0 ;
        }
    }

    int res = dfs(1,n) ;

    if(res==0)
    {
        printf("IMPOSSIBLE\n") ;
        return 0 ;
    }

    int cur = 0 ;

    color(1,cur) ;

    for(int i=1 ; i<=n ; i++)
    {
        printf("%d ",ans[i]) ;
    }
    printf("\n") ;

    return 0 ;
}

/*
8
6
2 3 L
7 8 L
1 3 L
6 7 R
4 5 R
2 5 R
*/


#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL)

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define maxn 1000005

pii tr[4*maxn] ;
int lazy[4*maxn] ;

void build(int cn, int b, int e)
{
    if(b==e)
    {
        tr[cn] = mp(0,b) ;
        return ;
    }
    int lc = cn*2 , rc=cn*2+1 , m = (b+e)/2 ;
    build(lc,b,m) ; build(rc,m+1,e) ;
    tr[cn] = min(tr[lc],tr[rc]) ;
    return ;
}

void relax(int cn, int b, int e)
{
    tr[cn].xx += lazy[cn] ;
    if(b!=e)
    {
        int lc = cn*2 , rc=cn*2+1 , m = (b+e)/2 ;
        lazy[lc] += lazy[cn] ;
        lazy[rc] += lazy[cn] ;
    }
    lazy[cn] = 0 ;
}

void update(int cn, int b, int e ,int l ,int r, int val)
{
    if( lazy[cn] != 0 ) relax(cn,b,e) ;
    if( b>r || e<l ) return ;
    if( b>=l && e<=r )
    {
        lazy[cn] += val ;
        relax(cn,b,e) ;
        return ;
    }
    int lc = cn*2 , rc=cn*2+1 , m = (b+e)/2 ;
    update(lc,b,m,l,r,val) ; update(rc,m+1,e,l,r,val) ;
    tr[cn] = min(tr[lc],tr[rc]) ;
}

pii query(int cn, int b, int e, int l, int r)
{
    if( lazy[cn] != 0 ) relax(cn,b,e) ;
    if( b>r || e<l ) return mp(INF,0) ;
    if(b>=l && e<=r) return tr[cn] ;

    int lc = cn*2 , rc=cn*2+1 , m = (b+e)/2 ;
    return min( query(lc,b,m,l,r) , query(rc,m+1,e,l,r) ) ;
}

vector<int> myChild[maxn] ;

int L[maxn] , R[maxn] ;
vector <int> Left[maxn] , Right[maxn] ;
vector <int> g[maxn] ;
int n ;

int dfs(int l ,int r)
{
    if(l>=r) return 1 ;
 //   if( Left[u].size() != 0 && Left[u][0] )

    for(int x:Left[l]) update(1,1,n,l+1,x,-1) ;
    for(int x:Right[l]) update(1,1,n,l+1,x,-1) ;

    int cur = l+1 ;

    if( Left[l].size() != 0 )
    {
        pii p = query(1,1,n,Left[l].back()+1,r) ;
        if( Right[l].size()>0 && ( p.xx !=0 || p.yy > Right[l][0] ) ) return 0 ;

        L[l] = l+1 ;
        cur = p.yy ;
        if(p.xx!=0) cur = r+1 ;

        int res = dfs( l+1 , cur-1 ) ;
        if( res==0 ) return res ;
    }

    if(cur>r) return 1 ;

    R[l] = cur ;
    int res = dfs(cur,r) ;
    if(res==0) return 0 ;

    return 1 ;
}

int ans[maxn] ;

void color( int u , int &cur )
{
    if( L[u] != 0  ) color(L[u],cur) ;
    cur++ ;
    ans[cur] = u ;
    if( R[u] ) color(R[u],cur) ;
}

int main()
{
    int c ;

    scanf("%d %d",&n,&c) ;

    for(int i=1 ; i<=c ; i++)
    {
        int u, v ;
        char s[10] ;
        scanf("%d %d %s",&u,&v,s) ;
        if( s[0]=='L' ) Left[u].pb(v) ;
        else Right[u].pb(v) ;
    }

    build(1,1,n) ;

    for(int i=1 ; i<=n ; i++)
    {
    //    printf("%d %d\n",Left[i].size() , Right[i].size()) ;
        sort( Left[i].begin() , Left[i].end() ) ;
        sort( Right[i].begin() , Right[i].end() ) ;
        for(int v:Left[i])
        {
            if( v<=i )
            {
                printf("IMPOSSIBLE\n") ;
                return 0 ;
            }
            update(1,1,n,i+1,v,1) ;
        }
        for(int v:Right[i])
        {
            if( v<=i )
            {
                printf("IMPOSSIBLE\n") ;
                return 0 ;
            }
            update(1,1,n,i+1,v,1) ;
        }

        if( Left[i].size() && Right[i].size() && Left[i].back() >= Right[i][0] )
        {
            printf("IMPOSSIBLE\n") ;
            return 0 ;
        }
    }

    int res = dfs(1,n) ;

    if(res==0)
    {
        printf("IMPOSSIBLE\n") ;
        return 0 ;
    }

    int cur = 0 ;

    color(1,cur) ;

    for(int i=1 ; i<=n ; i++)
    {
        printf("%d ",ans[i]) ;
    }
    printf("\n") ;

    return 0 ;
}

/*
8
6
2 3 L
7 8 L
1 3 L
6 7 R
4 5 R
2 5 R
*/


//const int N = 1e6+5;
//vi ans;
//vi l[N],r[N];
//int nxt = 0;
//bool contra = false;
//void dfs(int cover_until){
//    int u = ++nxt;
//    int cover_left = 0;
//    for(int v : l[u]){
//        cover_left = max(cover_left,v);
//        if(v <= nxt){
//            contra = true;
//            return;
//        }
//    }
//    int max_left = MOD;
//    for(int v : r[u]){
//        max_left = min(max_left,v-1);
//        cover_until = max(cover_until,v);
//    }
//    if(cover_left > max_left){
//        contra = true;
//        return;
//    }
//    if(cover_left > nxt)
//        dfs(cover_left);
//    if(nxt > max_left){
//        contra = true;
//        return;
//    }
//    ans.pb(u);
//    if(cover_until > nxt)
//        dfs(cover_until);
//}
//void _(){
//    int n,m;
//    cin >> n >> m;
//    rep(i,m){
//        int u,v;
//        string w;
//        cin >> u >> v >> w;
//        if(w == "LEFT")
//            l[u].pb(v);
//        else
//            r[u].pb(v);
//    }
//    dfs(n);
//    if(contra)
//        print "IMPOSSIBLE";
//    else
//        print ans;
//
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_ZERO_INT(i,r) for(int i = 0; i < r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT,REP_ZERO_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout)
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }
    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
T1 ostream& operator<<(ostream& stream, const vector<T>& t){
    for(int i = 0; i < sz(t); ++i){
        stream << t[i];
        if(i+1 < sz(t))
            stream << ' ';
    }
    return stream;
}
const int N = 1e6+5;
vi ans;
vi l[N],r[N];
int nxt = 0;
bool contra = false;
void dfs(int cover_until){
    int u = ++nxt;
    int cover_left = 0;
    for(int v : l[u]){
        cover_left = max(cover_left,v);
        if(v <= nxt){
            contra = true;
            return;
        }
    }
    int max_left = MOD;
    for(int v : r[u]){
        max_left = min(max_left,v-1);
        cover_until = max(cover_until,v);
    }
    if(cover_left > max_left){
        contra = true;
        return;
    }
    if(cover_left > nxt)
        dfs(cover_left);
    if(nxt > max_left){
        contra = true;
        return;
    }
    ans.pb(u);
    if(cover_until > nxt)
        dfs(cover_until);
}
void _(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int u,v;
        string w;
        cin >> u >> v >> w;
        if(w == "LEFT")
            l[u].pb(v);
        else
            r[u].pb(v);
    }
    dfs(n);
    if(contra)
        print "IMPOSSIBLE";
    else
        print ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


#include <bits/stdc++.h>

const int MAXN = 1e6 + 10;

void bye() {
	std::cout << "IMPOSSIBLE" << std::endl;
	exit(0);
}
struct info {
	int v, at;
} tr[MAXN << 2];
info operator + (info a, info b) {
	return a.v < b.v ? a : b;
}
int tag[MAXN << 2];
void mkadd(int x, int v) {
	tr[x].v += v;
	tag[x] += v;
}
void pushdown(int u) {
	if (int & t = tag[u]) {
		mkadd(u << 1, t);
		mkadd(u << 1 | 1, t);
		t = 0;
	}
}
void mdf(int u, int l, int r, int L, int R, int v) {
	if (L <= l && r <= R) return mkadd(u, v);
	int mid = l + r >> 1;
	pushdown(u);
	if (L <= mid) mdf(u << 1, l, mid, L, R, v);
	if (mid < R) mdf(u << 1 | 1, mid + 1, r, L, R, v);
	tr[u] = tr[u << 1] + tr[u << 1 | 1];
}
info qry(int u, int l, int r, int L, int R) {
	if (L <= l && r <= R) return tr[u];
	int mid = l + r >> 1;
	pushdown(u);
	info res = (info) {0x3f3f3f3f, -1};
	if (L <= mid) res = qry(u << 1, l, mid, L, R);
	if (mid < R) res = res + qry(u << 1 | 1, mid + 1, r, L, R);
	return res;
}
void build(int u, int l, int r) {
	tr[u].at = l;
	if (l == r) return ;
	int mid = l + r >> 1;
	build(u << 1, l, mid);
	build(u << 1 | 1, mid + 1, r);
}
std::vector<int> out[MAXN][2];
int n, m;
int ansl[MAXN], bak;
void solve(int l, int r) {
	if (l >= r) {
		if (l == r)
			ansl[++bak] = l;
		return ;
	}
	std::sort(out[l][0].begin(), out[l][0].end());
	std::sort(out[l][1].begin(), out[l][1].end());
	int L = l, R = r;
	if (!out[l][0].empty())
		L = out[l][0].back();
	if (!out[l][1].empty())
		R = out[l][1][0];
	if (L >= R) bye();
	for (auto t : out[l][0])
		mdf(1, 1, n, l, t - 1, -1);
	for (auto t : out[l][1])
		mdf(1, 1, n, l, t - 1, -1);
	info ret = qry(1, 1, n, L, R - 1);
	if (ret.v > 1) bye();
	solve(l + 1, ret.at);
	ansl[++bak] = l;
	solve(ret.at + 1, r);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	build(1, 1, n);
	for (int i = 1; i <= m; ++i) {
		int x, y; static char buf[100];
		std::cin >> x >> y >> buf;
		if (x >= y) bye();
		out[x][*buf == 'R'].push_back(y);
		mdf(1, 1, n, x, y - 1, 1);
	}
	solve(1, n);
	for (int i = 1; i <= n; ++i)
		std::cout << ansl[i] << (" \n" [i == n]);
	return 0;
}


#include <bits/stdc++.h>

const int MAXN = 1e6 + 10;

void bye() {
	std::cout << "IMPOSSIBLE" << std::endl;
	exit(0);
}
struct info {
	int v, at;
} tr[MAXN << 2];
info operator + (info a, info b) {
	return a.v < b.v ? a : b;
}
int tag[MAXN << 2];
void mkadd(int x, int v) {
	tr[x].v += v;
	tag[x] += v;
}
void pushdown(int u) {
	if (int & t = tag[u]) {
		mkadd(u << 1, t);
		mkadd(u << 1 | 1, t);
		t = 0;
	}
}
void mdf(int u, int l, int r, int L, int R, int v) {
	if (L <= l && r <= R) return mkadd(u, v);
	int mid = l + r >> 1;
	pushdown(u);
	if (L <= mid) mdf(u << 1, l, mid, L, R, v);
	if (mid < R) mdf(u << 1 | 1, mid + 1, r, L, R, v);
	tr[u] = tr[u << 1] + tr[u << 1 | 1];
}
info qry(int u, int l, int r, int L, int R) {
	if (L <= l && r <= R) return tr[u];
	int mid = l + r >> 1;
	pushdown(u);
	info res = (info) {0x3f3f3f3f, -1};
	if (L <= mid) res = qry(u << 1, l, mid, L, R);
	if (mid < R) res = res + qry(u << 1 | 1, mid + 1, r, L, R);
	return res;
}
void build(int u, int l, int r) {
	tr[u].at = l;
	if (l == r) return ;
	int mid = l + r >> 1;
	build(u << 1, l, mid);
	build(u << 1 | 1, mid + 1, r);
}
std::vector<int> out[MAXN][2];
int n, m;
int ansl[MAXN], bak;
void solve(int l, int r) {
	if (l >= r) {
		if (l == r)
			ansl[++bak] = l;
		return ;
	}
	std::sort(out[l][0].begin(), out[l][0].end());
	std::sort(out[l][1].begin(), out[l][1].end());
	int L = l + 1, R = r;
	if (!out[l][0].empty())
		L = out[l][0].back();
	if (!out[l][1].empty())
		R = out[l][1][0];
	if (L >= R) bye();
	for (auto t : out[l][0])
		mdf(1, 1, n, l, t - 1, -1);
	for (auto t : out[l][1])
		mdf(1, 1, n, l, t - 1, -1);
	info ret = qry(1, 1, n, L, R - 1);
	if (ret.v > 1) bye();
	solve(l + 1, ret.at);
	ansl[++bak] = l;
	solve(ret.at + 1, r);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	build(1, 1, n);
	for (int i = 1; i <= m; ++i) {
		int x, y; static char buf[100];
		std::cin >> x >> y >> buf;
		if (x >= y) bye();
		out[x][*buf == 'R'].push_back(y);
		mdf(1, 1, n, x, y - 1, 1);
	}
	solve(1, n);
	for (int i = 1; i <= n; ++i)
		std::cout << ansl[i] << (" \n" [i == n]);
	return 0;
}


#include <bits/stdc++.h>

const int MAXN = 1e6 + 10;

void bye() {
	std::cout << "IMPOSSIBLE" << std::endl;
	exit(0);
}
struct info {
	int v, at;
} tr[MAXN << 2];
info operator + (info a, info b) {
	return a.v < b.v ? a : b;
}
int tag[MAXN << 2];
void mkadd(int x, int v) {
	tr[x].v += v;
	tag[x] += v;
}
void pushdown(int u) {
	if (int & t = tag[u]) {
		mkadd(u << 1, t);
		mkadd(u << 1 | 1, t);
		t = 0;
	}
}
void mdf(int u, int l, int r, int L, int R, int v) {
	if (L <= l && r <= R) return mkadd(u, v);
	int mid = l + r >> 1;
	pushdown(u);
	if (L <= mid) mdf(u << 1, l, mid, L, R, v);
	if (mid < R) mdf(u << 1 | 1, mid + 1, r, L, R, v);
	tr[u] = tr[u << 1] + tr[u << 1 | 1];
}
info qry(int u, int l, int r, int L, int R) {
	if (L <= l && r <= R) return tr[u];
	int mid = l + r >> 1;
	pushdown(u);
	info res = (info) {0x3f3f3f3f, -1};
	if (L <= mid) res = qry(u << 1, l, mid, L, R);
	if (mid < R) res = res + qry(u << 1 | 1, mid + 1, r, L, R);
	return res;
}
void build(int u, int l, int r) {
	tr[u].at = l;
	if (l == r) return ;
	int mid = l + r >> 1;
	build(u << 1, l, mid);
	build(u << 1 | 1, mid + 1, r);
}
std::vector<int> out[MAXN][2];
int n, m;
int ansl[MAXN], bak;
void solve(int l, int r) {
	if (l >= r) {
		if (l == r)
			ansl[++bak] = l;
		return ;
	}
	std::sort(out[l][0].begin(), out[l][0].end());
	std::sort(out[l][1].begin(), out[l][1].end());
	int L = l, R = r + 1;
	if (!out[l][0].empty())
		L = out[l][0].back();
	if (!out[l][1].empty())
		R = out[l][1][0];
	if (L >= R) bye();
	for (auto t : out[l][0])
		mdf(1, 1, n, l, t - 1, -1);
	for (auto t : out[l][1])
		mdf(1, 1, n, l, t - 1, -1);
	info ret = qry(1, 1, n, L, R - 1);
	if (ret.v >= 1) bye();
	solve(l + 1, ret.at);
	ansl[++bak] = l;
	solve(ret.at + 1, r);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	build(1, 1, n);
	for (int i = 1; i <= m; ++i) {
		int x, y; static char buf[100];
		std::cin >> x >> y >> buf;
		if (x >= y) bye();
		out[x][*buf == 'R'].push_back(y);
		mdf(1, 1, n, x, y - 1, 1);
	}
	solve(1, n);
	for (int i = 1; i <= n; ++i)
		std::cout << ansl[i] << (" \n" [i == n]);
	return 0;
}