#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;
}


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

const int N = 1e5 + 100, LOG = 20;

vector<pair<int,string>> in[N];
vector<pair<int,string>> out[N];
int mx[N][LOG];
int mn[N][LOG];
int lg[N];

void preprocess(int n) {
    for(int i = 1; i <= n; i++) {
        mx[i][0] = 0;
        for(auto t : out[i]) mx[i][0] = max(mx[i][0], t.first);
        mn[i][0] = n+1;
        for(auto t : in[i]) mn[i][0] = min(mn[i][0], t.first);
    }
    for(int j = 1; j < LOG; j++) {
        for(int i = 1; i+(1<<j)-1 <= n; i++) {
            mx[i][j] = max(mx[i][j-1], mx[i+(1<<(j-1))][j-1]);
            mn[i][j] = min(mn[i][j-1], mn[i+(1<<(j-1))][j-1]);
        }
    }
    for(int i = 2; i < N; i++) lg[i] = lg[i/2] + 1;
}

int queryMax(int i, int j) {
    int k = lg[j-i+1];
    return max(mx[i][k], mx[j-(1<<k)+1][k]);
}

int queryMin(int i, int j) {
    int k = lg[j-i+1];
    return min(mn[i][k], mn[j-(1<<k)+1][k]);
}

vector<int> res;

void solve(int l, int r) {
    if(l == r) {
        res.push_back(l);
        return;
    }
    int ll = -1, rr = r+1;
    for(auto t : out[l]) {
        if(t.second == "LEFT") ll = max(ll, t.first);
        else rr = min(rr, t.first);
    }
    if(ll == -1) {
        solve(l+1, r);
        res.push_back(l);
    }
    else if(rr == r+1) {
        res.push_back(l);
        solve(l+1, r);
    }
    else {
        while(true) {
            if(ll >= rr) {
                cout << "IMPOSSIBLE" << endl;
                exit(0);
            }
            int new_l = queryMax(l+1, ll);
            if(new_l <= ll) {
                solve(l+1, ll);
                res.push_back(l);
                solve(ll+1, r);
                break;
            }
            ll = new_l;
            if(ll >= rr) {
                cout << "IMPOSSIBLE" << endl;
                exit(0);
            }
            ll = new_l;

            int new_r = queryMin(rr, r);
            if(new_r >= rr) {
                solve(l+1, rr-1);
                res.push_back(l);
                solve(rr, r);
                break;
            }
            rr = new_r;
            if(ll >= rr) {
                cout << "IMPOSSIBLE" << endl;
                exit(0);
            }
        }
    }
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, q;
    cin >> n >> q;
    for(int i = 1; i <= q; i++) {
        int a, b;
        string s;
        cin >> a >> b >> s;
        if(a >= b) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
        }
        out[a].push_back({b, s});
        in[b].push_back({a, s});
    }
    preprocess(n);
    solve(1, n);
    for(int x : res) cout << x << " ";

    return 0;
}


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

const int N = 1e6 + 100;

int inf = 1e9;
pair<int,int> tr[4*N];
int lz[4*N];

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

void propagate(int u, int st, int en) {
    if (!lz[u]) return;
    tr[u].first += lz[u];
    if (st!=en) {
        lz[2*u] += lz[u];
        lz[2*u+1] += lz[u];
    }
    lz[u] = 0;
}

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;
        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]);
    }
}

pair<int,int> query(int u, int st, int en, int l, int r) {
    propagate(u, st, en);
    if (r<st || en<l)  return make_pair(inf, inf);
    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));
    }
}

vector<pair<int,string>> out[N];
int n, q;

void solve() {
    stack<pair<int,int>> stk;
    vector<int> res;
    stk.push({1, n});
    while(!stk.empty()) {
        pair<int,int> tt = stk.top();
        stk.pop();
        int l = tt.first, r = tt.second;
        if(l == r) {
            res.push_back(l);
            continue;
        }
        if(r == 0) {
            res.push_back(l);
            continue;
        }
        int ll = -1, rr = r+1;
        for(auto t : out[l]) {
            if(t.second == "LEFT") ll = max(ll, t.first);
            else rr = min(rr, t.first);
            update(1,1,n-1,l,t.first-1,-1);
        }
        if(ll == -1) {
            stk.push({l, 0});
            stk.push({l+1, r});
        }
        else if(rr == r+1) {
            res.push_back(l);
            stk.push({l+1, r});
        }
        else {
            if(ll >= rr) {
                cout << "IMPOSSIBLE" << endl;
                exit(0);
            }
            pair<int,int> t = query(1,1,n-1,ll,rr-1);
            if(t.first > 0) {
                cout << "IMPOSSIBLE" << endl;
                exit(0);
            }
            stk.push({t.second+1, r});
            stk.push({l, 0});
            stk.push({l+1, t.second});
        }
    }
    for(int x : res) cout << x << " ";
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

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

    solve();

    return 0;
}


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

const int N = 1e6 + 100;

int inf = 1e9;
pair<int,int> tr[4*N];
int lz[4*N];

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

void propagate(int u, int st, int en) {
    if (!lz[u]) return;
    tr[u].first += lz[u];
    if (st!=en) {
        lz[2*u] += lz[u];
        lz[2*u+1] += lz[u];
    }
    lz[u] = 0;
}

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;
        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]);
    }
}

pair<int,int> query(int u, int st, int en, int l, int r) {
    propagate(u, st, en);
    if (r<st || en<l)  return make_pair(inf, inf);
    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));
    }
}

vector<int> res;
vector<pair<int,string>> out[N];
int n, q;

void solve(int l, int r) {
    if(l == r) {
        res.push_back(l);
        return;
    }
    int ll = -1, rr = r+1;
    for(auto t : out[l]) {
        if(t.second == "LEFT") ll = max(ll, t.first);
        else rr = min(rr, t.first);
        update(1,1,n-1,l,t.first-1,-1);
    }
    if(ll == -1) {
        solve(l+1, r);
        res.push_back(l);
    }
    else if(rr == r+1) {
        res.push_back(l);
        solve(l+1, r);
    }
    else {
        if(ll >= rr) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
        }
        pair<int,int> t = query(1,1,n-1,ll,rr-1);
        if(t.first > 0) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
        }
        solve(l+1, t.second);
        res.push_back(l);
        solve(t.second+1, r);
    }
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> q;
    if(n == 1) {
        cout << "IMPOSSIBLE" << endl;
        exit(0);
    }
    build(1,1,n-1);
    for(int i = 1; i <= q; i++) {
        int a, b;
        string s;
        cin >> a >> b >> s;
        if(a >= b) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
        }
        out[a].push_back({b, s});
        update(1,1,n-1,a,b-1,+1);
    }
    solve(1, n);
    for(int x : res) cout << x << " ";

    return 0;
}


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

const int N = 1e6 + 100;

int inf = 1e9;
pair<int,int> tr[4*N];
int lz[4*N];

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

void propagate(int u, int st, int en) {
    if (!lz[u]) return;
    tr[u].first += lz[u];
    if (st!=en) {
        lz[2*u] += lz[u];
        lz[2*u+1] += lz[u];
    }
    lz[u] = 0;
}

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;
        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]);
    }
}

pair<int,int> query(int u, int st, int en, int l, int r) {
    propagate(u, st, en);
    if (r<st || en<l)  return make_pair(inf, inf);
    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));
    }
}

vector<int> res;
vector<pair<int,string>> out[N];
int n, q;

void solve(int l, int r) {
    if(l == r) {
        res.push_back(l);
        return;
    }
    int ll = -1, rr = r+1;
    for(auto t : out[l]) {
        if(t.second == "LEFT") ll = max(ll, t.first);
        else rr = min(rr, t.first);
        update(1,1,n-1,l,t.first-1,-1);
    }
    if(ll == -1) {
        solve(l+1, r);
        res.push_back(l);
    }
    else if(rr == r+1) {
        res.push_back(l);
        solve(l+1, r);
    }
    else {
        if(ll >= rr) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
        }
        pair<int,int> t = query(1,1,n-1,ll,rr-1);
        if(t.first > 0) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
        }
        solve(t.second, rr-1);
        res.push_back(l);
        solve(rr, r);
    }
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> q;
    if(n == 1) {
        cout << "IMPOSSIBLE" << endl;
        exit(0);
    }
    build(1,1,n-1);
    for(int i = 1; i <= q; i++) {
        int a, b;
        string s;
        cin >> a >> b >> s;
        if(a >= b) {
            cout << "IMPOSSIBLE" << endl;
            exit(0);
        }
        out[a].push_back({b, s});
        update(1,1,n-1,a,b-1,+1);
    }
    solve(1, n);
    for(int x : res) cout << x << " ";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Seg {
  pair<int, int> mn = make_pair(1e7, 1e7); // <value, pos>
  void recalc(const Seg &lhs_seg, int lhs_len,
    const Seg &rhs_seg, int rhs_len) {
    mn = min(lhs_seg.mn, rhs_seg.mn);
  }
};

struct Lazy {
  int add;
  int assign_idx; // LLONG_MIN if no assign;
  void init() {
    add = 0;
    assign_idx = INT_MIN;
  }
  Lazy() { init(); }
  void split(Lazy &lhs_lazy, Lazy &rhs_lazy, int len) {
    lhs_lazy = *this;
    rhs_lazy = *this;
    init();
  }
  void merge(Lazy &oth, int len) {
    add += oth.add;
    assign_idx = max(assign_idx, oth.assign_idx);
  }
  void apply_to_seg(Seg &cur, int len) const {
    cur.mn.first += add;
    if (assign_idx != INT_MIN) {
      cur.mn.second = assign_idx;
    }
  }
};

struct Node { // Following code should not need to be
              // modified
  int ver;
  bool is_lazy = false;
  Seg seg;
  Lazy lazy;
  Node *lc = NULL, *rc = NULL;
  void init() {
    if (!lc) {
      lc = new Node{ver};
      rc = new Node{ver};
    }
  }
  Node *upd(
    int L, int R, int l, int r, Lazy &val, int tar_ver) {
    if (ver != tar_ver) {
      Node *rep = new Node(*this);
      rep->ver = tar_ver;
      return rep->upd(L, R, l, r, val, tar_ver);
    }
    if (L >= l && R <= r) {
      val.apply_to_seg(seg, R - L);
      lazy.merge(val, R - L);
      is_lazy = true;
    } else {
      init();
      int M = (L + R) / 2;
      if (is_lazy) {
        Lazy l_val, r_val;
        lazy.split(l_val, r_val, R - L);
        lc = lc->upd(L, M, L, M, l_val, ver);
        rc = rc->upd(M, R, M, R, r_val, ver);
        is_lazy = false;
      }
      Lazy l_val, r_val;
      val.split(l_val, r_val, R - L);
      if (l < M) lc = lc->upd(L, M, l, r, l_val, ver);
      if (M < r) rc = rc->upd(M, R, l, r, r_val, ver);
      seg.recalc(lc->seg, M - L, rc->seg, R - M);
    }
    return this;
  }
  void get(int L, int R, int l, int r, Seg *&lft_res,
    Seg *&tmp, bool last_ver) {
    if (L >= l && R <= r) {
      tmp->recalc(*lft_res, L - l, seg, R - L);
      swap(lft_res, tmp);
    } else {
      init();
      int M = (L + R) / 2;
      if (is_lazy) {
        Lazy l_val, r_val;
        lazy.split(l_val, r_val, R - L);
        lc = lc->upd(L, M, L, M, l_val, ver + last_ver);
        lc->ver = ver;
        rc = rc->upd(M, R, M, R, r_val, ver + last_ver);
        rc->ver = ver;
        is_lazy = false;
      }
      if (l < M)
        lc->get(L, M, l, r, lft_res, tmp, last_ver);
      if (M < r)
        rc->get(M, R, l, r, lft_res, tmp, last_ver);
    }
  }
};

struct SegTree { // indexes start from 0, ranges are
                 // [beg, end)
  vector<Node *> roots; // versions start from 0
  int len;
  SegTree(int _len) : len(_len) {
    roots.push_back(new Node{0});
  }
  int upd(
    int l, int r, Lazy &val, bool new_ver = false) {
    Node *cur_root = roots.back()->upd(
      0, len, l, r, val, roots.size() - !new_ver);
    if (cur_root != roots.back())
      roots.push_back(cur_root);
    return roots.size() - 1;
  }
  Seg get(int l, int r, int ver = -1) {
    if (ver == -1) ver = roots.size() - 1;
    Seg seg1, seg2;
    Seg *pres = &seg1, *ptmp = &seg2;
    roots[ver]->get(
      0, len, l, r, pres, ptmp, roots.size() - 1);
    return *pres;
  }
};

const int MAX_N = 1e6 + 5;

vector<pair<int, int>> conds [MAX_N];
vector<int> ans;

void solve (int root, int l, int r, SegTree &segTree) {
  int vr = r;
  int vl = l;

  for (pair<int, int> pr : conds[root]) {
    if (pr.second == 0) {
      vl = max(vl, pr.first);
    } else {
      vr = min(vr, pr.first);
    }

    Lazy tmp;
    tmp.add = -1;
    segTree.upd(root, pr.first, tmp);
  }

  if (vl >= vr) {
    cout << "IMPOSSIBLE" << endl;
    exit(0);
  }

  pair<int, int> mid = segTree.get(vl, vr).mn;
  if (mid.first > 0) {
    cout << "IMPOSSIBLE" << endl;
    exit(0);
  }

  if (root < mid.second) {
    solve(root + 1, root + 1, mid.second + 1, segTree);
  }
  ans.push_back(root);
  if (mid.second + 1 < r) {
    solve(mid.second + 1, mid.second + 1, r, segTree);
  }
}

int main () {
  ios::sync_with_stdio(false);

  int vertexc, condc;
  cin >> vertexc >> condc;

  SegTree segTree (1 << 21);
  for (int i = 0; i <= vertexc; i++) {
    Lazy tmp;
    tmp.assign_idx = i;
    tmp.add = -1e7;

    segTree.upd(i, i + 1, tmp);
  }

  for (int i = 0; i < condc; i++) {
    int par, ch;
    string dir;
    cin >> par >> ch >> dir;

    if (ch <= par) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }

    Lazy tmp;
    tmp.add = 1;
    segTree.upd(par, ch, tmp);

    if (dir[0] == 'L') {
      conds[par].push_back(make_pair(ch, 0));
    } else {
      conds[par].push_back(make_pair(ch, 1));
    }
  }

  solve(1, 1, vertexc + 1, segTree);

  for (int u : ans) {
    cout << u << " ";
  }
  cout << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Seg {
  pair<int, int> mn = make_pair(1e7, 1e7); // <value, pos>
  void recalc(const Seg &lhs_seg, int lhs_len,
    const Seg &rhs_seg, int rhs_len) {
    mn = min(lhs_seg.mn, rhs_seg.mn);
  }
};

struct Lazy {
  int add;
  int assign_idx; // LLONG_MIN if no assign;
  void init() {
    add = 0;
    assign_idx = INT_MIN;
  }
  Lazy() { init(); }
  void split(Lazy &lhs_lazy, Lazy &rhs_lazy, int len) {
    lhs_lazy = *this;
    rhs_lazy = *this;
    init();
  }
  void merge(Lazy &oth, int len) {
    add += oth.add;
    assign_idx = max(assign_idx, oth.assign_idx);
  }
  void apply_to_seg(Seg &cur, int len) const {
    cur.mn.first += add;
    if (assign_idx != INT_MIN) {
      cur.mn.second = assign_idx;
    }
  }
};

struct Node { // Following code should not need to be
              // modified
  int ver;
  bool is_lazy = false;
  Seg seg;
  Lazy lazy;
  Node *lc = NULL, *rc = NULL;
  void init() {
    if (!lc) {
      lc = new Node{ver};
      rc = new Node{ver};
    }
  }
  Node *upd(
    int L, int R, int l, int r, Lazy &val, int tar_ver) {
    if (ver != tar_ver) {
      Node *rep = new Node(*this);
      rep->ver = tar_ver;
      return rep->upd(L, R, l, r, val, tar_ver);
    }
    if (L >= l && R <= r) {
      val.apply_to_seg(seg, R - L);
      lazy.merge(val, R - L);
      is_lazy = true;
    } else {
      init();
      int M = (L + R) / 2;
      if (is_lazy) {
        Lazy l_val, r_val;
        lazy.split(l_val, r_val, R - L);
        lc = lc->upd(L, M, L, M, l_val, ver);
        rc = rc->upd(M, R, M, R, r_val, ver);
        is_lazy = false;
      }
      Lazy l_val, r_val;
      val.split(l_val, r_val, R - L);
      if (l < M) lc = lc->upd(L, M, l, r, l_val, ver);
      if (M < r) rc = rc->upd(M, R, l, r, r_val, ver);
      seg.recalc(lc->seg, M - L, rc->seg, R - M);
    }
    return this;
  }
  void get(int L, int R, int l, int r, Seg *&lft_res,
    Seg *&tmp, bool last_ver) {
    if (L >= l && R <= r) {
      tmp->recalc(*lft_res, L - l, seg, R - L);
      swap(lft_res, tmp);
    } else {
      init();
      int M = (L + R) / 2;
      if (is_lazy) {
        Lazy l_val, r_val;
        lazy.split(l_val, r_val, R - L);
        lc = lc->upd(L, M, L, M, l_val, ver + last_ver);
        lc->ver = ver;
        rc = rc->upd(M, R, M, R, r_val, ver + last_ver);
        rc->ver = ver;
        is_lazy = false;
      }
      if (l < M)
        lc->get(L, M, l, r, lft_res, tmp, last_ver);
      if (M < r)
        rc->get(M, R, l, r, lft_res, tmp, last_ver);
    }
  }
};

struct SegTree { // indexes start from 0, ranges are
                 // [beg, end)
  vector<Node *> roots; // versions start from 0
  int len;
  SegTree(int _len) : len(_len) {
    roots.push_back(new Node{0});
  }
  int upd(
    int l, int r, Lazy &val, bool new_ver = false) {
    Node *cur_root = roots.back()->upd(
      0, len, l, r, val, roots.size() - !new_ver);
    if (cur_root != roots.back())
      roots.push_back(cur_root);
    return roots.size() - 1;
  }
  Seg get(int l, int r, int ver = -1) {
    if (ver == -1) ver = roots.size() - 1;
    Seg seg1, seg2;
    Seg *pres = &seg1, *ptmp = &seg2;
    roots[ver]->get(
      0, len, l, r, pres, ptmp, roots.size() - 1);
    return *pres;
  }
};

const int MAX_N = 1e6 + 5;

vector<pair<int, int>> conds [MAX_N];
vector<int> ans;

void solve (int root, int l, int r, SegTree &segTree) {
  int vr = r;
  int vl = l;

  for (pair<int, int> pr : conds[root]) {
    if (pr.second == 0) {
      vl = max(vl, pr.first);
    } else {
      vr = min(vr, pr.first);
    }

    Lazy tmp;
    tmp.add = -1;
    segTree.upd(root, pr.first, tmp);
  }

  if (vl >= vr) {
    cout << "IMPOSSIBLE" << endl;
    exit(0);
  }

  pair<int, int> mid = segTree.get(vl, vr).mn;
  if (mid.first > 0) {
    cout << "IMPOSSIBLE" << endl;
    exit(0);
  }

  if (root < mid.second) {
    solve(root + 1, root + 1, mid.second + 1, segTree);
  }
  ans.push_back(root);
  if (mid.second + 1 < r) {
    solve(mid.second + 1, mid.second + 1, r, segTree);
  }
}

int main () {
  ios::sync_with_stdio(false);

  int vertexc, condc;
  cin >> vertexc >> condc;

  SegTree segTree (1 << 21);
  for (int i = 0; i <= vertexc; i++) {
    Lazy tmp;
    tmp.assign_idx = i;
    tmp.add = -1e7;

    segTree.upd(i, i + 1, tmp);
  }

  for (int i = 0; i < condc; i++) {
    int par, ch;
    string dir;
    cin >> par >> ch >> dir;

    if (ch < par) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }

    Lazy tmp;
    tmp.add = 1;
    segTree.upd(par, ch, tmp);

    if (dir[0] == 'L') {
      conds[par].push_back(make_pair(ch, 0));
    } else {
      conds[par].push_back(make_pair(ch, 1));
    }
  }

  solve(1, 1, vertexc + 1, segTree);

  for (int u : ans) {
    cout << u << " ";
  }
  cout << endl;
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 1000000001
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, t, p=0;
vector<int> L[1000001];
vector<int> R[1000001];
string s;
int l, r;
vector<int> ans;
int bad=0;

void start(int k, int mn, int mx)
{
	k++;
	p++;

	if (mn >= mx || k >= mx) bad=1;
	if (bad) return;

	int y=0, f=n+1, d=0;
	For(i,0,L[k].size())
		y=max(y,L[k][i]);
	For(i,0,R[k].size())
	{
		f=min(f,R[k][i]);
		d=max(d,R[k][i]);
	}
	if (max(y,d)>=mx || y>=f)
	{
		bad=1;
		return;
	}

	if (k<y) start(k, y, min(mx,f));
	ans.PB(k);
	if (p<mn || p<d) start(p, max(d,mn), mx);
}

void main()
{
	scanf("%d%d",&n,&p);
	For(i,0,p)
	{
		scanf("%d%d",&l,&r);
		if (r<=l) {cout<<"IMPOSSIBLE"; return;}
		cin>>s;
		if (s=="LEFT") L[l].PB(r);
		else R[l].PB(r);
	}
	p=0;
	start(0, n, n+1);
	if (bad) cout<<"IMPOSSIBLE";
	else
		For(i,0,ans.size()) cout<<ans[i]<<" ";
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 1000000001
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, t, p=0;
vector<int> L[1000001];
vector<int> R[1000001;
string s;
int l, r;
vector<int> ans;
int bad=0;

void start(int k, int mn, int mx)
{
	k++;
	p++;

	if (mn >= mx || k >= mx) bad=1;
	if (bad) return;

	int y=0, f=n+1, d=0;
	For(i,0,L[k].size())
		y=max(y,L[k][i]);
	For(i,0,R[k].size())
	{
		f=min(f,R[k][i]);
		d=max(d,R[k][i]);
	}
	if (max(y,d)>=mx || y>=f)
	{
		bad=1;
		return;
	}

	if (k<y) start(k, y, min(mx,f));
	ans.PB(k);
	if (p<mn || p<d) start(p, max(d,mn), mx);
}

void main()
{
	scanf("%d%d",&n,&p);
	For(i,0,p)
	{
		scanf("%d%d",&l,&r);
		if (r<=l) {cout<<"IMPOSSIBLE"; return;}
		cin>>s;
		if (s=="LEFT") L[l].PB(r);
		else R[l].PB(r);
	}
	p=0;
	start(0, n, n+1);
	if (bad) cout<<"IMPOSSIBLE";
	else
		For(i,0,ans.size()) cout<<ans[i]<<" ";
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <time.h>
#include <sstream>
#include <fstream>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define I insert
#define mod 1000000007
#define INF 1000000001
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int n, t, p=0;
vector<int> L[100001];
vector<int> R[100001];
string s;
int l, r;
vector<int> ans;
int bad=0;

void start(int k, int mn, int mx)
{
	k++;
	p++;

	if (mn >= mx || k >= mx) bad=1;
	if (bad) return;

	int y=0, f=n+1, d=0;
	For(i,0,L[k].size())
		y=max(y,L[k][i]);
	For(i,0,R[k].size())
	{
		f=min(f,R[k][i]);
		d=max(d,R[k][i]);
	}
	if (max(y,d)>=mx || y>=f)
	{
		bad=1;
		return;
	}

	if (k<y) start(k, y, min(mx,f));
	ans.PB(k);
	if (p<mn || p<d) start(p, max(d,mn), mx);
}

void main()
{
	scanf("%d%d",&n,&p);
	For(i,0,p)
	{
		scanf("%d%d",&l,&r);
		if (r<=l) {cout<<"IMPOSSIBLE"; return;}
		cin>>s;
		if (s=="LEFT") L[l].PB(r);
		else R[l].PB(r);
	}
	p=0;
	start(0, n, n+1);
	if (bad) cout<<"IMPOSSIBLE";
	else
		For(i,0,ans.size()) cout<<ans[i]<<" ";
}


#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <cassert>
#include <queue>
#include <stack>
#include <limits>
using namespace std;
typedef long long ll;
#define M_PI       3.14159265358979323846
int grl[1000007],grr[1000007],deg[1000007],L[1000007],R[1000007],RR[1000007],n;
vector <int> ans;
int leaf=2;
bool q=true;
void dfs(int v,int mx,bool pp){
    if(leaf<=mx) {
        if(pp) grl[v]=leaf++;
        else grr[v]=leaf++;
        v=leaf-1;
    }
    //if(leaf>mx) return;
    if(L[v]) dfs(v,L[v],true);
    if(v<n&&(RR[v]<leaf||L[v]>=RR[v])) q=false;
    if(R[v]>=leaf||leaf<=mx) dfs(v,max(mx,R[v]),false);
    return;
}
void dfs1(int v){
    if(!grl[v]&&!grr[v]) {ans.push_back(v); return;}
    if(grl[v]) dfs1(grl[v]);
    ans.push_back(v);
    if(grr[v]) dfs1(grr[v]);
}
char s[107];
int main(){
    ios_base::sync_with_stdio(false);
    int c;
    scanf("%d %d",&n,&c);
    if(n==1&&c>=1){ printf("IMPOSSIBLE"); return 0;}
    for(int i=1;i<=n;i++) RR[i]=1000007;
    int a,b,lc=0,rc=0,lmax=0,rmin=1000007;
    for(int i=1;i<=c;i++){
        scanf("%d %d %s",&a,&b,&s);
        if(a>=b){ printf("IMPOSSIBLE"); return 0;}
        if(s[0]=='L') L[a]=max(L[a],b);
        else R[a]=max(R[a],b),RR[a]=min(RR[a],b);
    }
    R[1]=max(R[1],n+2);
    dfs(1,1,true);
    if(!q) { printf("IMPOSSIBLE"); return 0;}
    leaf--;
    while(leaf<n){
        int t=leaf+1;
        grl[leaf]=t;
        leaf++;
    }
    dfs1(1);
    for(int i=0;i<n;i++) printf("%d ",ans[i]);
    //cin>>n;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <set>
#include <map>
#include <cassert>
#include <algorithm>
#include <ctime>
#include <iomanip>

using namespace std;

#define mp make+pair
#define sz size()
#define all(x) x.begin(),x.end()
#define forn(i,n) for (int i = 0; i<int(n); i++)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int INF = 1e9 + 7;
const ld EPS = 1e-14;

//#define DEBUG
#ifdef DEBUG
    #define PL(x) cout<<#x<<" = "<<x<<endl
    #define PR(x) cout<<#x<<" = "<<x<<" "
#else
    #define PL(x) {}
    #define PR(x) {}
#endif

const int MAXN = 1000007;
int N, C;
int last = -1, l1[MAXN], l2[MAXN], r1[MAXN], r2[MAXN];
vector<int> ans;
char res = true;

void dfs(int x){
    int i = ++last;
    /*PL(i+1); PL(x+1); cout << endl;*/
    if (l1[i] != -1){
        if (l1[i] <= last) { res = false; return; }
        dfs(l2[i]);
        if (!res) return;
    }
    ans.push_back(i);
    if (r1[i] != -1){
        if (r1[i] <= last){ res = false; return; }
        dfs(max(x, r2[i]));
        if (!res) return;
    }
    else if (x>last) dfs(x);
}

int main(){
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    cin >> N >> C;
    forn(i, MAXN) l1[i] = l2[i] = r1[i] = r2[i] = -1;

    forn(i, C){
        int a, b;
        cin >> a >> b; a--; b--;
        string s; cin >> s;
        if (s == "LEFT"){
            l1[a] = ((l1[a] >= 0) ? min(l1[a], b) : b);
            l2[a] = max(l2[a], b);
        }
        else{
            r1[a] = ((r1[a] >= 0) ? min(r1[a], b) : b);
            r2[a] = max(r2[a], b);
        }
    }
    dfs(N - 1);

    if (res) forn(i,ans.sz) cout << ans[i]+1 << " ";
    else printf("IMPOSSIBLE");

#ifdef DEBUG
    cerr << "Time elapsed: " << (ld)clock() / CLOCKS_PER_SEC << " sec." << endl;
#endif
}


										/* in the name of Allah */
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

#define uint unsigned int
#define int64 long long
#define P pair<int, int>
#define Pss pair<string, string>
#define PLL pair<int64, int64>
#define Inf 1000000
#define Mod 1000000007LL
#define Max 1000010
int n, c;
int l[Max], r[Max], e[Max];
bool mark[Max];

void print(int idx){
	mark[idx] = true;
	for(int i = idx + 1; i <= l[idx]; i++)
		if(!mark[i])
			print(i);
	cout << idx + 1 << ' ';
	for(int i = l[idx] + 1; i <= e[idx]; i++)
		if(!mark[i])
			print(i);
}

int main(){
	cin >> n >> c;
	int a, b;
	string str;
	for(int i = 0; i < n; i++){
		e[i] = l[i] = i;
		r[i] = n;
	}
	for(int i = 0; i < c; i++){
		cin >> a >> b >> str;
		a--, b--;
		if(a >= b){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		if(str[0] == 'L')
			l[a] = max(l[a], b);
		else r[a] = min(r[a], b);
		e[a] = max(e[a], b);
	}

	for(int idx = n - 1; idx >= 0; idx--){
		for(int i = idx + 1; i <= l[idx]; i++)
			l[idx] = max(l[idx], e[i]);
		e[idx] = max(e[idx], l[idx]);
		for(int i = l[idx] + 1; i <= e[idx]; i++)
			e[idx] = max(e[idx], e[i]);
		if(r[idx] <= l[idx]){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
	}

	memset(mark, false, sizeof mark);
	e[0] = n - 1;
	print(0);
	cout << endl;
	return 0;
}


										/* in the name of Allah */
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

#define uint unsigned int
#define int64 long long
#define P pair<int, int>
#define Pss pair<string, string>
#define PLL pair<int64, int64>
#define Inf 1000000
#define Mod 1000000007LL
#define Max 1000010
int n, c;
int l[Max], r[Max], e[Max];
bool mark[Max];

void print(int idx){
	for(int i = idx + 1; i <= l[idx]; ){
		print(i);
		i = e[i] + 1;
	}
	cout << idx + 1 << ' ';
	for(int i = l[idx] + 1; i <= e[idx]; ){
		print(i);
		i = e[i] + 1;
	}
}

int main(){
	cin >> n >> c;
	int a, b;
	string str;
	for(int i = 0; i < n; i++){
		e[i] = l[i] = i;
		r[i] = n;
	}
	for(int i = 0; i < c; i++){
		cin >> a >> b >> str;
		a--, b--;
		if(a >= b){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		if(str[0] == 'L')
			l[a] = max(l[a], b);
		else r[a] = min(r[a], b);
		e[a] = max(e[a], b);
	}

	for(int idx = n - 1; idx >= 0; idx--){

		for(int i = idx + 1; i <= l[idx]; ){
			l[idx] = max(l[idx], e[i]);
			i = e[i] + 1;
		}

		e[idx] = max(e[idx], l[idx]);

		for(int i = l[idx] + 1; i <= e[idx]; ){
			e[idx] = max(e[idx], e[i]);
			i = e[i] + 1;
		}

		if(r[idx] <= l[idx]){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
	}
	memset(mark, false, sizeof mark);
	e[0] = n - 1;
	print(0);
	cout << endl;
	return 0;
}


										/* in the name of Allah */
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

#define uint unsigned int
#define int64 long long
#define P pair<int, int>
#define Pss pair<string, string>
#define PLL pair<int64, int64>
#define Inf 1000000
#define Mod 1000000007LL
#define Max 1000010
int n, c;
int l[Max], r[Max], e[Max];
bool mark[Max];

void dfs(int idx){
	mark[idx] = true;
	for(int i = idx + 1; i <= l[idx]; i++){
		if(!mark[i])
			dfs(i);
		l[idx] = max(l[idx], e[i]);
	}
	e[idx] = max(e[idx], l[idx]);
	for(int i = l[idx] + 1; i <= e[idx]; i++){
		if(!mark[i])
			dfs(i);
		e[idx] = max(e[idx], e[i]);
	}
}

void print(int idx){
	mark[idx] = true;
	for(int i = idx + 1; i <= l[idx]; i++)
		if(!mark[i])
			print(i);
	cout << idx + 1 << ' ';
	for(int i = l[idx] + 1; i <= e[idx]; i++)
		if(!mark[i])
			print(i);
}

int main(){
	cin >> n >> c;
	int a, b;
	string str;
	for(int i = 0; i < n; i++){
		e[i] = l[i] = i;
		r[i] = n;
	}
	for(int i = 0; i < c; i++){
		cin >> a >> b >> str;
		a--, b--;
		if(a >= b){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		if(str[0] == 'L')
			l[a] = max(l[a], b);
		else r[a] = min(r[a], b);
		e[a] = max(e[a], b);
	}

	for(int i = 0; i < n; i++){
		if(!mark[i])
			dfs(i);
		if(r[i] <= l[i]){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
	}
	memset(mark, false, sizeof mark);
	e[0] = n - 1;
	print(0);
	cout << endl;
	return 0;
}


										/* in the name of Allah */
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

#define uint unsigned int
#define int64 long long
#define P pair<int, int>
#define Pss pair<string, string>
#define PLL pair<int64, int64>
#define Inf 1000000
#define Mod 1000000007LL
#define Max 1000010
int n, c;
int l[Max], r[Max], e[Max];
bool mark[Max];

void print(int idx){
	for(int i = idx + 1; i <= l[idx]; ){
		print(i);
		i = e[i] + 1;
	}
	cout << idx + 1 << ' ';
	for(int i = l[idx] + 1; i <= e[idx]; ){
		print(i);
		i = e[i] + 1;
	}
}

int main(){
	cin >> n >> c;
	int a, b;
	string str;
	for(int i = 0; i < n; i++){
		e[i] = l[i] = i;
		r[i] = n;
	}
	for(int i = 0; i < c; i++){
		cin >> a >> b >> str;
		a--, b--;
		if(a >= b){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		if(str[0] == 'L')
			l[a] = max(l[a], b);
		else r[a] = min(r[a], b);
		e[a] = max(e[a], b);
	}

	for(int idx = n - 1; idx >= 0; idx--){
		for(int i = idx + 1; i <= l[idx]; i++)
			l[idx] = max(l[idx], e[i]);
		e[idx] = max(e[idx], l[idx]);
		for(int i = l[idx] + 1; i <= e[idx]; i++)
			e[idx] = max(e[idx], e[i]);
		if(r[idx] <= l[idx]){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
	}
	memset(mark, false, sizeof mark);
	e[0] = n - 1;
	print(0);
	cout << endl;
	return 0;
}


										/* in the name of Allah */
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

#define uint unsigned int
#define int64 long long
#define P pair<int, int>
#define Pss pair<string, string>
#define PLL pair<int64, int64>
#define Inf 1000000
#define Mod 1000000007LL
#define Max 1000010
int n, c;
int l[Max], r[Max], e[Max];
bool mark[Max];

void print(int idx){
	mark[idx] = true;
	for(int i = idx + 1; i <= l[idx]; i++)
		if(!mark[i])
			print(i);
	cout << idx + 1 << ' ';
	for(int i = l[idx] + 1; i <= e[idx]; i++)
		if(!mark[i])
			print(i);
}

int main(){
	cin >> n >> c;
	int a, b;
	string str;
	for(int i = 0; i < n; i++){
		e[i] = l[i] = i;
		r[i] = n;
	}
	for(int i = 0; i < c; i++){
		cin >> a >> b >> str;
		a--, b--;
		if(a >= b){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		if(str[0] == 'L')
			l[a] = max(l[a], b);
		else r[a] = min(r[a], b);
		e[a] = max(e[a], b);
	}

	for(int idx = n - 1; idx >= 0; idx--){
		for(int i = idx + 1; i <= l[idx]; i++)
			l[idx] = max(l[idx], e[i]);
		e[idx] = max(e[idx], l[idx]);
		for(int i = l[idx] + 1; i <= e[idx]; i++)
			e[idx] = max(e[idx], e[i]);
	}

	for(int i = 0; i < n; i++){
		if(!mark[i])
			dfs(i);
		if(r[i] <= l[i]){
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
	}
	memset(mark, false, sizeof mark);
	e[0] = n - 1;
	print(0);
	cout << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cmath>
using namespace std;

typedef long long ll;
#define X first
#define Y second
#define mp make_pair

const int N = (int)1e6 + 100;
vector <int> leftChild[N], rightChild[N];
int maxLeft[N], minLeft[N];
int maxRight[N], minRight[N];

#define index ajsdhkads
char com[10];
int answer[N];
int index = 0;

int mv = 2;

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

int solve(int v, int maxV)
{
	if (v > maxV)
		return maxV;
	if (leftChild[v].size() > 0)
	{
		int mx = solve(mv++, maxLeft[v]);
		if (rightChild[v].size() > 0 && mx >= minRight[v])
			fail();
		answer[index++] = v;
		if (mv <= max(maxRight[v], maxV))
			return solve(mv++, max(maxV, maxRight[v]));
		return max(maxV, mx);
	}
	answer[index++] = v;
	if (mv <= max(maxRight[v], maxV))
		return solve(mv++, max(maxV, maxRight[v]));
	return maxV;
}

int main()
{
	int n, c;
	scanf("%d%d", &n, &c);
	for (int i = 0; i < c; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		if (a >= b)
			fail();
		scanf(" %s", com);
		if (com[0] == 'L')
			leftChild[a].push_back(b);
		else
			rightChild[a].push_back(b);
	}
	for (int i = 1; i <= n; i++)
	{
		if (leftChild[i].size() > 0)
		{
			minLeft[i] = *min_element(leftChild[i].begin(), leftChild[i].end());
			maxLeft[i] = *max_element(leftChild[i].begin(), leftChild[i].end());
		}

		if (rightChild[i].size() > 0)
		{
			minRight[i] = *min_element(rightChild[i].begin(), rightChild[i].end());
			maxRight[i] = *max_element(rightChild[i].begin(), rightChild[i].end());
		}
	}

	solve(1, n);
	for (int i = 0; i < index; i++)
		printf("%d ", answer[i]);

	return 0;
}


#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <cassert>
#include <bitset>
#include <ctime>
#include <cmath>

#define forn(i,n) for(int i = 0; i < int(n); ++i)
#define sz(a) int(a.size())
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()

using namespace std;

typedef long long li;
typedef long double ld;

typedef pair<int,int> pt;
#define ft first
#define sc second

const li INF64 = li(1e18);
const int INF = int(1e9);
const ld EPS = 1e-9;

int n, c;

const int N = 100 + 5;

int din[N];
int son[2][N];
vector <int> ch[N][2];

bool read() {
    if (!(cin >> n >> c))
        return false;
    forn(i, n)
        son[0][i] = son[1][i] = -1;
    forn(i, c) {
        int a, b;
        string s;
        cin >> a >> b >> s;
        --a, --b;
        ch[a][s[0] == 'R'].pb(b);
        din[b]++;
    }
    return true;
}

priority_queue <int> fr;
bool good = true;
bool used[N];

void add_free() {
    forn(i, n)
        if (i && !used[i] && din[i] == 0) {
            used[i] = true;
            fr.push(-i);
        }
}

int sz = 0;

int build() {
    int v = sz++;
    used[v] = true;

    forn(t, 2) {
        int cmx = -1;
        forn(i, sz(ch[v][t])) {
            int c = ch[v][t][i];

            if (c < sz)
                good = false;

            cmx = max(c, cmx);
        }

        if (cmx >= sz)
            son[t][v] = build();

        while (cmx >= sz) {
            int s =sz - 1;
            son[1][s] = build();
        }
    }

    if (v == 0)
        while (n != sz) {
            int s =sz - 1;
            son[1][s] = build();
        }

    return v;
}

int last = -1;

bool check(int v) {
    if (v == -1)
        return true;
    if (v != last + 1)
        return false;
    last = v;
    return check(son[0][v]) && check(son[1][v]);
}

void outsym(int v) {
    if (v == -1)
        return;
    outsym(son[0][v]);
    cout << v + 1 << " ";
    outsym(son[1][v]);
}

void solve() {
    build();

    good &= check(0);

    if (good)
        outsym(0);
    else
        puts("IMPOSSIBLE");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    cout << fixed << setprecision(15);

    while (read())
        solve();

    return 0;
}


#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <cassert>
#include <bitset>
#include <ctime>
#include <cmath>

#define forn(i,n) for(int i = 0; i < int(n); ++i)
#define sz(a) int(a.size())
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()

using namespace std;

typedef long long li;
typedef long double ld;

typedef pair<int,int> pt;
#define ft first
#define sc second

const li INF64 = li(1e18);
const int INF = int(1e9);
const ld EPS = 1e-9;

int n, c;

const int N = 1000000 + 5;

int din[N];
int son[2][N];
vector <int> ch[N][2];

bool read() {
    if (!(cin >> n >> c))
        return false;
    forn(i, n)
        son[0][i] = son[1][i] = -1;
    forn(i, c) {
        int a, b;
        string s;
        cin >> a >> b >> s;
        --a, --b;
        ch[a][s[0] == 'R'].pb(b);
        din[b]++;
    }
    return true;
}

priority_queue <int> fr;
bool good = true;
bool used[N];

void add_free() {
    forn(i, n)
        if (i && !used[i] && din[i] == 0) {
            used[i] = true;
            fr.push(-i);
        }
}

int sz = 0;

int build() {
    int v = sz++;
    used[v] = true;

    forn(t, 2) {
        int cmx = -1;
        forn(i, sz(ch[v][t])) {
            int c = ch[v][t][i];

            if (c < sz)
                good = false;

            cmx = max(c, cmx);
        }

        if (cmx >= sz)
            son[t][v] = build();

        while (cmx >= sz) {
            int s =sz - 1;
            son[1][s] = build();
        }
    }

    if (v == 0)
        while (n != sz) {
            int s =sz - 1;
            son[1][s] = build();
        }

    return v;
}

int last = -1;

bool check(int v) {
    if (v == -1)
        return true;
    if (v != last + 1)
        return false;
    last = v;
    return check(son[0][v]) && check(son[1][v]);
}

void outsym(int v) {
    if (v == -1)
        return;
    outsym(son[0][v]);
    cout << v + 1 << " ";
    outsym(son[1][v]);
}

void solve() {
    build();

    good &= check(0);

    if (good)
        outsym(0);
    else
        puts("IMPOSSIBLE");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    cout << fixed << setprecision(15);

    while (read())
        solve();

    return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<math.h>
#include<queue>
#include<algorithm>
#include <fstream>
#include<set>
#include<map>
typedef long long ll;
using namespace std;
#define maxn 1000005
#define mod 1000000009
struct xx{
    int u,v;
    char s[10];
    xx(){};
    xx(int a,int b,char * c){
        u=a,v=b,strcpy(s,c);
    }
}x[maxn];
vector<int> q;
int n,m;
int lmax[maxn];
int rmax[maxn],rmin[maxn];
bool mark[maxn];
bool sign=1;
int dfs_t=2;
void dfs(int l,int r){
    if(!sign) return ;
    if(lmax[l]) dfs(dfs_t++,lmax[l]);
    q.push_back(l);
    if(dfs_t>rmin[l]){sign=false;return;}
    r=max(r,rmax[l]);
    if(dfs_t<=r) dfs(dfs_t++,r);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<=n;i++) lmax[i]=rmax[i]=0,rmin[i]=n+1;
    for(int i=0;i<m;i++){
        int a,b;
        char s[10];
        scanf("%d%d%s",&a,&b,s);
        if(a>=b) sign=0;
        if(s[0]=='L') lmax[a]=max(lmax[a],b);
        else rmax[a]=max(rmax[a],b),rmin[a]=min(rmin[a],b);
    }
    dfs(1,n);
    if(!sign) puts("IMPOSSIBLE");
    else
        for(int i=0;i<n;i++) printf("%d ",q[i]);
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<math.h>
#include<queue>
#include<algorithm>
#include <fstream>
#include<set>
#include<map>
typedef long long ll;
using namespace std;
#define maxn 2005
#define mod 1000000009
struct xx{
    int u,v;
    char s[10];
    xx(){};
    xx(int a,int b,char * c){
        u=a,v=b,strcpy(s,c);
    }
}x[maxn];
vector<int> q;
int n,m;
int lmax[maxn];
int rmax[maxn],rmin[maxn];
bool mark[maxn];
bool sign=1;
int dfs_t=2;
void dfs(int l,int r){
    if(!sign) return ;
    if(lmax[l]) dfs(dfs_t++,lmax[l]);
    q.push_back(l);
    if(dfs_t>rmin[l]){sign=false;return;}
    r=max(r,rmax[l]);
    if(dfs_t<=r) dfs(dfs_t++,r);
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<=n;i++) lmax[i]=rmax[i]=0,rmin[i]=n+1;
    for(int i=0;i<m;i++){
        int a,b;
        char s[10];
        scanf("%d%d%s",&a,&b,s);
        if(a>=b) sign=0;
        if(s[0]=='L') lmax[a]=max(lmax[a],b);
        else rmax[a]=max(rmax[a],b),rmin[a]=min(rmin[a],b);
    }
    dfs(1,n);
    if(!sign) puts("IMPOSSIBLE");
    else
        for(int i=0;i<n;i++) printf("%d ",q[i]);
}


#pragma comment(linker,"/STACK:102400000,102400000")
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <algorithm>
#include <bitset>
#include <functional>
#include <numeric>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <iterator>
#include <memory>
#include <utility>
#include <string>
#include <sstream>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define mset(a) memset(a,0,sizeof(a))
#define mmset(a) memset(a,-1,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

typedef double lf;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<lf,lf> pdd;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<pii> vpii;

const int inf=1000000007;
const ll linf=1000000000000000000LL;
const ull ulinf=(1ULL<<63)-10ULL;
const lf eps=0.000001;
const lf pi=3.14159265358979323846;

template <class T> T abs(T a){return a>=0?a:-a;}
template <class T> int sign(T a){return a>eps?1:a<-eps?-1:0;}
template <class T> T sqr(T a){return a*a;}
template <class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template <class T> T mod(T a,T b){T ret=a%b;if(ret<0)ret+=b;return ret;}
template <class T> T lowbit(T x){return x&-x;}
ll addmod(ll a,ll b,ll c){return ((a+b)%c+c)%c;}
ll mulmod(ll a,ll b,ll c){if(b==0LL)return 0LL;ll ret=mulmod(a,b>>1,c);ret=(ret+ret)%c;if(b&1LL)ret=(ret+a)%c;return ret;}
ll powmod(ll a,ll b,ll c){if(b==0LL)return 1LL;ll ret=powmod(a,b>>1,c);ret=ret*ret%c;if(b&1LL)ret=ret*a%c;return ret;}
ll modinv(ll a,ll b){return powmod(a,b-2LL,b);}
template <class T> void maxe(T &a,T b){if(a<b)a=b;}
template <class T> void mine(T &a,T b){if(a>b)a=b;}
int iszero(lf a){return a<=eps&&a>=-eps;}

template <class T> void geti(T &a){a=0;int b=0;char c;while((c=getchar())==' '||c=='\n');if(c=='-')b=1;else a=c-48;while((c=getchar())!=' '&&c!='\n')a=a*10+c-48;if(b)a=-a;}

void fileio_in_out(){freopen(".in","r",stdin);freopen(".out","w",stdout);}
void fileio_txt(){freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}

//==================================================

#define DEBUG(X)

const int N=1111111;
const int M=222;
const int K=20;
const ll md=inf;

int test;
int n,m,k,ans;
int a[N];
char s[11];
int f[N];
pii p[N];
int ord[N];

void dfs(int x)
{
    ord[x]=++k;
    if(p[x].X)
        dfs(p[x].X);
    if(p[x].Y)
        dfs(p[x].Y);
}

void dfs2(int x)
{
    if(p[x].X)
        dfs2(p[x].X);
    printf("%d ",x);
    if(p[x].Y)
        dfs2(p[x].Y);
}

int getans()
{
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d%s",&x,&y,s);
        if(y==1)
            return 0;
        if(f[y])
            return 0;
        if(s[0]=='L')
        {
            if(!p[x].X)
            {
                p[x].X=y;
                f[y]=x;
            }
            else
                return 0;
        }
        else
        {
            if(!p[x].Y)
            {
                p[x].Y=y;
                f[y]=x;
            }
            else
                return 0;
        }
    }
    for(int i=2;i<=n;i++)
        if(!f[i])
        {
            if(!p[i-1].X)
            {
                p[i-1].X=i;
                f[i]=i-1;
            }
            else
                return 0;
        }
    k=0;
    dfs(1);
    for(int i=1;i<=n;i++)
        if(ord[i]!=i)
            return 0;
    return 1;
}

int main()
{
    //fileio_in_out();
    //fileio_txt();
    //ios::sync_with_stdio(false);cout<<setprecision(15);

    scanf("%d%d",&n,&m);
    ans=getans();
    if(ans)
    {
        dfs2(1);
        puts("");
    }
    else
        puts("IMPOSSIBLE");

    //system("pause");
    return 0;
}


#pragma comment(linker,"/STACK:102400000,102400000")
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <algorithm>
#include <bitset>
#include <functional>
#include <numeric>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <iterator>
#include <memory>
#include <utility>
#include <string>
#include <sstream>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define mset(a) memset(a,0,sizeof(a))
#define mmset(a) memset(a,-1,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

typedef double lf;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<lf,lf> pdd;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<pii> vpii;

const int inf=1000000007;
const ll linf=1000000000000000000LL;
const ull ulinf=(1ULL<<63)-10ULL;
const lf eps=0.000001;
const lf pi=3.14159265358979323846;

template <class T> T abs(T a){return a>=0?a:-a;}
template <class T> int sign(T a){return a>eps?1:a<-eps?-1:0;}
template <class T> T sqr(T a){return a*a;}
template <class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template <class T> T mod(T a,T b){T ret=a%b;if(ret<0)ret+=b;return ret;}
template <class T> T lowbit(T x){return x&-x;}
ll addmod(ll a,ll b,ll c){return ((a+b)%c+c)%c;}
ll mulmod(ll a,ll b,ll c){if(b==0LL)return 0LL;ll ret=mulmod(a,b>>1,c);ret=(ret+ret)%c;if(b&1LL)ret=(ret+a)%c;return ret;}
ll powmod(ll a,ll b,ll c){if(b==0LL)return 1LL;ll ret=powmod(a,b>>1,c);ret=ret*ret%c;if(b&1LL)ret=ret*a%c;return ret;}
ll modinv(ll a,ll b){return powmod(a,b-2LL,b);}
template <class T> void maxe(T &a,T b){if(a<b)a=b;}
template <class T> void mine(T &a,T b){if(a>b)a=b;}
int iszero(lf a){return a<=eps&&a>=-eps;}

template <class T> void geti(T &a){a=0;int b=0;char c;while((c=getchar())==' '||c=='\n');if(c=='-')b=1;else a=c-48;while((c=getchar())!=' '&&c!='\n')a=a*10+c-48;if(b)a=-a;}

void fileio_in_out(){freopen(".in","r",stdin);freopen(".out","w",stdout);}
void fileio_txt(){freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}

//==================================================

#define DEBUG(X)

const int N=1111111;
const int M=222;
const int K=20;
const ll md=inf;

int test;
int n,m,k,ans;
char s[11];
int aa[N];
vi lson[N],rson[N];

int dfs(int l,int r)
{
    int ret=l;
    if(lson[l].size())
    {
        int mx=0;
        for(int i=0;i<lson[l].size();i++)
            maxe(mx,lson[l][i]);
        ret=dfs(l+1,mx);
        if(!ret)
            return 0;
    }
    aa[++k]=l;
    if(rson[l].size())
    {
        int mx=0;
        for(int i=0;i<rson[l].size();i++)
        {
            maxe(mx,rson[l][i]);
            if(rson[l][i]<=ret)
                return 0;
        }
        maxe(r,mx);
    }
    if(ret<r)
        ret=dfs(ret+1,r);
    return ret;
}

int getans()
{
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d%s",&x,&y,s);
        if(x>=y)
            return 0;
        if(s[0]=='L')
            lson[x].pb(y);
        else
            rson[x].pb(y);
    }
    int ret=dfs(1,n);
    return ret;
}

int main()
{
    //fileio_in_out();
    //fileio_txt();
    //ios::sync_with_stdio(false);cout<<setprecision(15);

    scanf("%d%d",&n,&m);
    ans=getans();
    if(ans)
    {
        for(int i=1;i<=n;i++)
            printf("%d ",aa[i]);
        puts("");
    }
    else
        puts("IMPOSSIBLE");

    //system("pause");
    return 0;
}


#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
#pragma comment(linker, "/STACK:256000000")
#define mp make_pair
#define pb push_back
#define all(C) (C).begin(), (C).end()
#define sz(C) (int)(C).size()
#define PRIME 1103
#define PRIME1 31415
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
//------------------------------------------------------------
struct tre
{
    int ls, rs;
    int lma, lmi, rma, rmi;
    tre ()
    {
        ls = -1, rs = -1;
        lma = -1; lmi = 1e9; rma = -1, rmi = 1e9;
    }
};

tre gr[2000000];

int build(int u, int m)
{
    if (u == m)
        return u;
    int k = u;
    if (gr[u].lmi < u)
    {
        cout << "IMPOSSIBLE";
        exit(0);
    }
    if (gr[u].rmi < u)
    {
        cout << "IMPOSSIBLE";
        exit(0);
    }
    if (gr[u].lma == -1)
    {
        gr[u].rs = u + 1;
        k = max(k, build(u + 1, m));
        return k;
    }
    if (gr[u].rma == -1)
    {
        gr[u].ls = u + 1;
        k = max(k, build(u + 1, m));
        return k ;
    }
    gr[u].ls = u + 1;
    int mid  = build(u + 1, gr[u].lma);
    gr[u].rs = mid + 1;
    if (mid > gr[u].rmi)
    {
        cout << "IMPOSSIBLE";
        exit(0);
    }
    k = max(k, build(mid + 1, max(m, gr[u].rma)));
    return k;
}

void ans(int u)
{
    if (gr[u].ls != -1)
        ans(gr[u].ls);

    printf("%d ", u + 1);

    if (gr[u].rs != -1)
        ans(gr[u].rs);
}
int n, c;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    scanf("%d %d\n", &n, &c);
    for(int i = 0; i < c; ++i)
    {
        int a, b;
        scanf("%d %d ", &a, &b);
        a--; b--;
        char p[20];
        scanf("%s", &p);
        if (p[0] == 'L')
        {
            gr[a].lma = max(gr[a].lma, b);
            gr[a].lmi = min(gr[a].lmi, b);
        }
        else
        {
            gr[a].rma = max(gr[a].rma, b);
            gr[a].rmi = min(gr[a].rmi, b);
        }
    }
    build(0, n - 1);
    ans(0);
}


#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
#pragma comment(linker, "/STACK:256000000")
#define mp make_pair
#define pb push_back
#define all(C) (C).begin(), (C).end()
#define sz(C) (int)(C).size()
#define PRIME 1103
#define PRIME1 31415
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
//------------------------------------------------------------
struct tre
{
    int ls, rs;
    int lma, lmi, rma, rmi;
    tre ()
    {
        ls = -1, rs = -1;
        lma = -1; lmi = 1e9; rma = -1, rmi = 1e9;
    }
};

tre gr[2000000];

int build(int u, int m)
{

    int k = u;
    m = max(gr[u].lma, m);
    m = max(gr[u].rma, m);
    if (gr[u].lmi <= u)
    {
        cout << "IMPOSSIBLE";
        exit(0);
    }
    if (gr[u].rmi <= u)
    {
        cout << "IMPOSSIBLE";
        exit(0);
    }
    if (u == m)
        return u;
    if (gr[u].lma == -1)
    {
        gr[u].rs = u + 1;
        k = max(k, build(u + 1, m));
        return k;
    }
    if (gr[u].rma == -1)
    {
        gr[u].ls = u + 1;
        k = max(k, build(u + 1, m));
        return k ;
    }
    gr[u].ls = u + 1;
    int mid  = build(u + 1, gr[u].lma);
    gr[u].rs = mid + 1;
    //cerr << u << ' ' << mid << endl;
    if (mid >= gr[u].rmi)
    {
        cout << "IMPOSSIBLE";
        exit(0);
    }
    k = max(k, build(mid + 1, max(m, gr[u].rma)));
    return k;
}

void ans(int u)
{
    if (gr[u].ls != -1)
        ans(gr[u].ls);

    printf("%d ", u + 1);

    if (gr[u].rs != -1)
        ans(gr[u].rs);
}
int n, c;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    scanf("%d %d\n", &n, &c);
    for(int i = 0; i < c; ++i)
    {
        int a, b;
        scanf("%d %d ", &a, &b);
        a--; b--;
        char p[20];
        scanf("%s", &p);
        if (p[0] == 'L')
        {
            gr[a].lma = max(gr[a].lma, b);
            gr[a].lmi = min(gr[a].lmi, b);
        }
        else
        {
            gr[a].rma = max(gr[a].rma, b);
            gr[a].rmi = min(gr[a].rmi, b);
        }
    }
    build(0, n - 1);
    ans(0);
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int parent[1000001];
int child[1000001];
char subtree[1000001];
int cid[1000001];

int ais[1000002];
int aie[1000002];
int temp[2000000];
int N,C;

bool cmp(int a,int b)
{
	if(parent[a]==parent[b])
	{
		if(subtree[a]==subtree[b])
			return child[a]<child[b];
		return subtree[a]<subtree[b];
	}
	return parent[a]<parent[b];
}
vector<int> ans;
int getLast(int i,int j)
{
	int first = ais[i];
	int last;
	for(last=first;parent[cid[last]]==i && subtree[cid[last]]=='L';last++)
		;
	if(last>first)
	{
		int nxt = getLast(i+1,child[cid[last-1]]);
		ans.push_back(i);
		if(nxt==-1) return -1;
		if((nxt>=child[cid[last]])&&(parent[cid[last]]==i)) return -1;
		int rlast = -1;
		if(nxt < j) rlast = max(rlast,j);
		if(parent[cid[last]]==i) rlast = max(rlast,child[cid[aie[i]]]);
		if(rlast > -1) return getLast(nxt+1,rlast);
		else return nxt;
	}
	else
	{
		ans.push_back(i);
		for(;parent[cid[last]]==i;last++)
			;
		if(last>first)
			return getLast(i+1,max(child[cid[last-1]],j));
		else if(i==j)
			return i;
		else
			return getLast(i+1,j);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	string s;
	cin >> N >> C;
	for(int i=0;i<C;i++)
	{
		cin >> parent[i] >> child[i] >> s;
		parent[i]--;
		child[i]--;
		if(parent[i] >= child[i])
		{
			cout << "IMPOSSIBLE\n";
			return 0;
		}
		subtree[i] = s[0];
		cid[i] = i;
	}
	parent[C] = 2000000;
	child[C] = 2000000;
	subtree[C] = ' ';
	cid[C] = C;
	C++;
	sort(cid,cid+C,cmp);
	for(int i=0;i<=N;i++)
		ais[i] = C-1;
	for(int i=(C-1);i>=0;i--)
		ais[parent[cid[i]]] = i;
	for(int i=0;i<C;i++)
		aie[parent[cid[i]]] = i;
	if(getLast(0,N-1)!=-1)
	{
		for(int i=0;i<N;i++)
			cout << ans[i]+1 << " ";
		cout << "\n";
	}
	else
		cout << "IMPOSSIBLE\n";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int parent[100001];
int child[100001];
char subtree[100001];
int cid[100001];

int ais[1000002];
int aie[1000002];

int N,C;

bool cmp(int a,int b)
{
	if(parent[a]==parent[b])
	{
		if(subtree[a]==subtree[b])
			return child[a]<child[b];
		return subtree[a]<subtree[b];
	}
	return parent[a]<parent[b];
}
vector<int> ans;
int getLast(int i,int j)
{
	int first = ais[i];
	int last;
	for(last=first;parent[cid[last]]==i && subtree[cid[last]]=='L';last++)
		;
	if(last>first)
	{
		int nxt = getLast(i+1,child[cid[last-1]]);
		ans.push_back(i);
		if(nxt==-1) return -1;
		if((nxt>=child[cid[last]])&&(parent[cid[last]]==i)) return -1;
		int rlast = -1;
		if(nxt < j) rlast = max(rlast,j);
		if(parent[cid[last]]==i) rlast = max(rlast,child[cid[aie[i]]]);
		if(rlast > -1) return getLast(nxt+1,rlast);
		else return nxt;
	}
	else
	{
		ans.push_back(i);
		for(;parent[cid[last]]==i;last++)
			;
		if(last>first)
			return getLast(i+1,max(child[cid[last-1]],j));
		else if(i==j)
			return i;
		else
			return getLast(i+1,j);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	string s;
	cin >> N >> C;
	for(int i=0;i<C;i++)
	{
		cin >> parent[i] >> child[i] >> s;
		parent[i]--;
		child[i]--;
		if(parent[i] >= child[i])
		{
			cout << "IMPOSSIBLE\n";
			return 0;
		}
		subtree[i] = s[0];
		cid[i] = i;
	}
	parent[C] = 2000000;
	child[C] = 2000000;
	subtree[C] = ' ';
	cid[C] = C;
	C++;
	sort(cid,cid+C,cmp);
	for(int i=0;i<=N;i++)
		ais[i] = C-1;
	for(int i=(C-1);i>=0;i--)
		if(parent[cid[i]] != 2000000)
			ais[parent[cid[i]]] = i;
	for(int i=0;i<C;i++)
		if(parent[cid[i]] != 2000000)
			aie[parent[cid[i]]] = i;
	if(getLast(0,N-1)!=-1)
	{
		for(int i=0;i<N;i++)
			cout << ans[i]+1 << " ";
		cout << "\n";
	}
	else
		cout << "IMPOSSIBLE\n";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int parent[1000001];
int child[1000001];
char subtree[1000001];
int cid[1000001];

int ais[1000001];
int aie[1000001];
int N,C;

bool cmp(int a,int b)
{
	if(parent[a]==parent[b])
	{
		if(subtree[a]==subtree[b])
			return child[a]<child[b];
		return subtree[a]<subtree[b];
	}
	return parent[a]<parent[b];
}
vector<int> ans;
int getLast(int i,int j)
{
	int first = ais[i];
	int last;
	for(last=first;parent[cid[last]]==i && subtree[cid[last]]=='L';last++)
		;
	if(last>first)
	{
		int nxt = getLast(i+1,child[cid[last-1]]);
		ans.push_back(i);
		if(nxt==-1) return -1;
		if((nxt>=child[cid[last]])&&(parent[cid[last]]==i)) return -1;
		int rlast = -1;
		if(nxt < j) rlast = max(rlast,j);
		if(parent[cid[last]]==i) rlast = max(rlast,child[cid[aie[i]]]);
		if(rlast > -1) return getLast(nxt+1,rlast);
		else return nxt;
	}
	else
	{
		ans.push_back(i);
		for(;parent[cid[last]]==i;last++)
			;
		if(last>first)
			return getLast(i+1,max(child[cid[last-1]],j));
		else if(i==j)
			return i;
		else
			return getLast(i+1,j);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	string s;
	cin >> N >> C;
	for(int i=0;i<C;i++)
	{
		cin >> parent[i] >> child[i] >> s;
		parent[i]--;
		child[i]--;
		subtree[i] = s[0];
		cid[i] = i;
	}
	parent[C] = 2000000;
	cid[C] = C;
	C++;
	sort(cid,cid+C,cmp);
	for(int i=0;i<=N;i++)
		ais[i] = C;
	for(int i=(C-1);i>=0;i--)
		ais[parent[cid[i]]] = i;
	for(int i=0;i<C;i++)
		aie[parent[cid[i]]] = i;
	if(getLast(0,N-1)!=-1)
	{
		for(int i=0;i<N;i++)
			cout << ans[i]+1 << " ";
		cout << "\n";
	}
	else
		cout << "IMPOSSIBLE\n";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int parent[1000001];
int child[1000001];
char subtree[1000001];
int cid[1000001];
int ais[1000002];
int aie[1000002];

int N,C;

bool cmp(int a,int b)
{
	if(parent[a]==parent[b])
	{
		if(subtree[a]==subtree[b])
			return child[a]<child[b];
		return subtree[a]<subtree[b];
	}
	return parent[a]<parent[b];
}
vector<int> ans;
int getLast(int i,int j)
{
	int first = ais[i];
	int last;
	for(last=first;parent[cid[last]]==i && subtree[cid[last]]=='L';last++)
		;
	if(last>first)
	{
		int nxt = getLast(i+1,child[cid[last-1]]);
		ans.push_back(i);
		if(nxt==-1) return -1;
		if((nxt>=child[cid[last]])&&(parent[cid[last]]==i)) return -1;
		int rlast = -1;
		if(nxt < j) rlast = max(rlast,j);
		if(parent[cid[last]]==i) rlast = max(rlast,child[cid[aie[i]]]);
		if(rlast > -1) return getLast(nxt+1,rlast);
		else return nxt;
	}
	else
	{
		ans.push_back(i);
		for(;parent[cid[last]]==i;last++)
			;
		if(last>first)
			return getLast(i+1,max(child[cid[last-1]],j));
		else if(i==j)
			return i;
		else
			return getLast(i+1,j);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	string s;
	cin >> N >> C;
	for(int i=0;i<C;i++)
	{
		cin >> parent[i] >> child[i] >> s;
		parent[i]--;
		child[i]--;
		if(parent[i] >= child[i])
		{
			cout << "IMPOSSIBLE\n";
			return 0;
		}
		subtree[i] = s[0];
		cid[i] = i;
	}
	parent[C] = 2000000;
	child[C] = 2000000;
	subtree[C] = ' ';
	cid[C] = C;
	C++;
	sort(cid,cid+C,cmp);
	for(int i=0;i<=N;i++)
		ais[i] = C-1;
	for(int i=(C-1);i>=0;i--)
		ais[parent[cid[i]]] = i;
	for(int i=0;i<C;i++)
		aie[parent[cid[i]]] = i;
	if(getLast(0,N-1)!=-1)
	{
		for(int i=0;i<N;i++)
			cout << ans[i]+1 << " ";
		cout << "\n";
	}
	else
		cout << "IMPOSSIBLE\n";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int ais[1000002];
int aie[1000002];
int parent[1000001];
int child[1000001];
char subtree[1000001];
int cid[1000001];
int N,C;

bool cmp(int a,int b)
{
	if(parent[a]==parent[b])
	{
		if(subtree[a]==subtree[b])
			return child[a]<child[b];
		return subtree[a]<subtree[b];
	}
	return parent[a]<parent[b];
}
vector<int> ans;
int getLast(int i,int j)
{
	int first = ais[i];
	int last;
	for(last=first;parent[cid[last]]==i && subtree[cid[last]]=='L';last++)
		;
	if(last>first)
	{
		int nxt = getLast(i+1,child[cid[last-1]]);
		ans.push_back(i);
		if(nxt==-1) return -1;
		if((nxt>=child[cid[last]])&&(parent[cid[last]]==i)) return -1;
		int rlast = -1;
		if(nxt < j) rlast = max(rlast,j);
		if(parent[cid[last]]==i) rlast = max(rlast,child[cid[aie[i]]]);
		if(rlast > -1) return getLast(nxt+1,rlast);
		else return nxt;
	}
	else
	{
		ans.push_back(i);
		for(;parent[cid[last]]==i;last++)
			;
		if(last>first)
			return getLast(i+1,max(child[cid[last-1]],j));
		else if(i==j)
			return i;
		else
			return getLast(i+1,j);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	string s;
	cin >> N >> C;
	for(int i=0;i<C;i++)
	{
		cin >> parent[i] >> child[i] >> s;
		parent[i]--;
		child[i]--;
		if(parent[i] >= child[i])
		{
			cout << "IMPOSSIBLE\n";
			return 0;
		}
		subtree[i] = s[0];
		cid[i] = i;
	}
	parent[C] = 2000000;
	child[C] = 2000000;
	subtree[C] = ' ';
	cid[C] = C;
	C++;
	sort(cid,cid+C,cmp);
	for(int i=0;i<=N;i++)
		ais[i] = C-1;
	for(int i=(C-1);i>=0;i--)
		ais[parent[cid[i]]] = i;
	for(int i=0;i<C;i++)
		aie[parent[cid[i]]] = i;
	if(getLast(0,N-1)!=-1)
	{
		for(int i=0;i<N;i++)
			cout << ans[i]+1 << " ";
		cout << "\n";
	}
	else
		cout << "IMPOSSIBLE\n";
	return 0;
}


#include<stdio.h>

int n, c;

/*
struct tree{
	int id;
	tree *l, *r;
	};
*/

int last_left[1000010], first_right[1000010], last_right[1000010];

//int fl_bad = 0;

char dst[10000000];
char *ptr = dst;

int build_tree (int id, int last_mand, int first_bad){
    if (last_mand < last_right[id])
        last_mand = last_right[id];
	if (last_mand >= first_bad)
		return 0;

	int last_used = id;
	if(last_left[id])
		last_used = build_tree(id + 1, last_left[id],
            first_right[id] ? first_right[id] : first_bad);
	if(! last_used)
		return 0;
	ptr += sprintf(ptr, "%d ", id);
	if(last_mand >= last_used + 1)
		return build_tree(last_used + 1, last_mand, first_bad);
	else
		return last_used;
	}

int main(){
	scanf("%d%d", &n, &c);
	int a, b;
	char s[10];
	for(int i = 0; i<c; i++){
		scanf("%d%d%s", &a, &b, s);
		if(a >= b){
			puts("IMPOSSIBLE");
			return 0;
			}
		if(s[0] == 'L'){
			if(!last_left[a] || last_left[a] < b)
				last_left[a] = b;
			}
		else{
			if(!last_right[a] || last_right[a] < b)
				last_right[a] = b;
			if(!first_right[a] || first_right[a] > b)
				first_right[a] = b;
			}
		if(first_right[a] && (last_left[a] >= first_right[a])){
			puts("IMPOSSIBLE");
			return 0;
			}
		}

	if (build_tree(1, n, n+1))
        puts(dst);
    else
        puts("IMPOSSIBLE");
    return 0;
	}


#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int l[1000010],r[1000010];
int ml[1000010];
int n,m,e;
vector<int>ans;
char str[100];

bool dfs(int i,int ll,int rr)
{
    bool ok=1;
    e++;
    ll=max(ll,ml[i]);
    if(l[i]>=r[i] || ll>=rr)
        return false;
    if(l[i]!=-1)
        ok&=dfs(i+1,l[i],min(r[i],rr));
    ans.push_back(i);
    if(e<=ll)
        ok&=dfs(e,ll,rr);
    return ok;
}

int main()
{
    scanf("%d%d",&n,&m);
    memset(l,-1,sizeof(l));
    memset(ml,-1,sizeof(ml));
    int i,j;
    for(i=0;i<n;i++)
        r[i]=1999999999;
    while(m--)
    {
        scanf("%d%d%s",&i,&j,&str);
        i--;
        j--;
        if(i>=j)
        {
            puts("IMPOSSIBLE");
            return 0;
        }
        if(str[0]=='R')
        {
            r[i]=min(r[i],j);
            ml[i]=max(ml[i],j);
        }
        else l[i]=max(l[i],j);
    }
    if(!dfs(0,n-1,n))
    {
        puts("IMPOSSIBLE");
        return 0;
    }
    for(i=0;i<ans.size();i++)
        printf("%d%c",ans[i]+1,i==n-1?'\n':' ');
    return 0;
}


#pragma comment(linker, "/STACK:10000000")
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
const int N = 1000005;
int a[N], b[N], maxc[N], maxl[N], minr[N];
string s[N];
vector<int> pr[N], fr[N];
vector<int> ans;

set<int> lefts;

void nope() {
    cout << "IMPOSSIBLE" << endl;
    exit(0);
}

int build(int i, int r) {
    r = max(r, maxc[i]);

    if (i == r) {
        ans.push_back(i);
        return i;
    }

    if (maxl[i] == 0) {
        ans.push_back(i);
        return build(i + 1, r);
    }

    int x = build(i + 1, maxl[i]);
    ans.push_back(i);

    F0(jj, SZ(fr[i])) {
        int k = fr[i][jj];
        if (s[k] == "RIGHT" && b[k] <= x) nope();
    }

    if (minr[i] < x) nope();
    if (x >= r) return x;

    return build(x + 1, r);
}

int main() {
    //freopen("x.in", "r", stdin);

    cin >> n >> m;
    F1(i, n) minr[i] = inf;
    F0(i, m) {
        cin >> a[i] >> b[i] >> s[i];
        if (a[i] >= b[i]) nope();
        if (s[i] == "LEFT") {
            maxl[a[i]] = max(maxl[a[i]], b[i]);
        }
        else {
            minr[a[i]] = min(minr[a[i]], b[i]);
        }
        pr[b[i]].push_back(i);
        fr[a[i]].push_back(i);
    }

    for (int i = n; i >= 1; i--) {
        maxc[i] = max(maxc[i], i);
        F0(jj, SZ(pr[i])) {
            int k = pr[i][jj];
            maxc[a[k]] = max(maxc[a[k]], maxc[i]);
        }
    }

    build(1, n);

    F0(i, n) cout << ans[i] << " ";

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:100000000")
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <fstream>
#include <iostream>
using namespace std;
#define N 1000100
int l[N], r[N], t[N], v[N], c, f, e;
void dfs(int i, int g, int h)
{
    e++;
    g=max(g, t[i]);
    if(r[i]<=l[i] || g>=h) { f=1; return; }
    if(l[i]!=-1)
    {
        dfs(i+1, l[i], min(r[i], h));
    }
    v[c++]=i;
    if(e<=g) dfs(e, g, h);
}
int main()
{
    int i, j, n, q;
    scanf("%d%d", &n, &q);
    for(i=0; i<n; l[i]=-1, r[i]=n, t[i]=-1, i++);
    for(; q--; )
    {
        char s[10];
        scanf("%d%d%s", &i, &j, s); i--; j--;
        if(i>=j) { printf("IMPOSSIBLE\n"); return 0; }
        if(s[0]=='L') l[i]=max(l[i], j);
        else { r[i]=min(r[i], j); t[i]=max(t[i], j); }
    }
    dfs(0, n-1, n);
    if(f) { printf("IMPOSSIBLE\n"); return 0; }
    for(i=0; i<n; printf("%d ", v[i]+1), i++);
    return 0;
}


#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <memory.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <conio.h>

using namespace std;

#pragma comment (linker, "/STACK:64000000")

#define pb push_back
#define pii pair<int, int>
#define pdi pair<double, int>
#define pdii pair<pdi, int>
#define pll pair<ll, ll>
#define pib pair<int, bool>
#define pli pair<ll, int>
#define vi vector<int>
#define inf 2000000000
#define mod 1000000007
#define mod2 536870911
#define y1 uhgeg
#define lim 31700
#define eps 1e-9
#define prime 3001

typedef long long ll;
typedef unsigned long long ull;

int n, j, i, h, g, k, q1, q2, q, t, x, y, sum, right_min[1000001], left_max[1000001], mx[1000001], tree[4000001];
char buf[10];
vector <vector <int> > l, r;

void update(int i, int p1, int p2, int q)
{
	if (p1 == p2)
	{
		tree[i] = mx[q];
		return;
	}
	int p = (p1 + p2) >> 1;
	if (q <= p)
	{
		update(i << 1, p1, p, q);
	}
	else
	{
		update((i << 1) + 1, p + 1, p2, q);
	}
	tree[i] = max(tree[i << 1], tree[(i << 1) + 1]);
}

int get_val(int i, int p1, int p2, int q1, int q2)
{
	if (q1 <= p1 && p2 <= q2)
	{
		return tree[i];
	}
	int p = (p1 + p2) >> 1, res1 = 0, res2 = 0;
	if (q1 <= p)
	{
		res1 = get_val(i << 1, p1, p, q1, q2);
	}
	if (q2 > p)
	{
		res2 = get_val((i << 1) + 1, p + 1, p2, q1, q2);
	}
	return max(res1, res2);
}

bool check(int v)
{
	for (int j = 0; j < l[v].size(); j++)
	{
		left_max[v] = max(mx[l[v][j]], left_max[v]);
		mx[v] = max(mx[l[v][j]], mx[v]);
	}
	for (int j = 0; j < r[v].size(); j++)
	{
		right_min[v] = min(r[v][j], right_min[v]);
		mx[v] = max(mx[r[v][j]], mx[v]);
	}
	if (left_max[v])
	{
		left_max[v] = max(left_max[v], get_val(1, 1, n, v + 1, left_max[v]));
	}
	if (mx[v])
	{
		mx[v] = max(mx[v], get_val(1, 1, n, v + 1, mx[v]));
	}
	else
	{
		mx[v] = v;
	}
	update(1, 1, n, v);
	return (right_min[v] > left_max[v]);
}

void dfs_print(int q1, int q2)
{
	//printf ("%d - %d\n", q1, q2);
	if (left_max[q1])
	{
		dfs_print(q1 + 1, left_max[q1]);
	}
	printf ("%d ", q1);
	if (left_max[q1] && left_max[q1] < q2)
	{
		dfs_print(left_max[q1] + 1, q2);
	}
	if (!left_max[q1] && q2 > q1)
	{
		dfs_print(q1 + 1, q2);
	}
}

void solve()
{
	scanf ("%d%d", &n, &k);
	l.resize(n + 1, vector<int>());
	r.resize(n + 1, vector<int>());
	memset(right_min, 127, sizeof(int) * (n + 1));
	for (j = 1; j <= k; j++)
	{
		scanf ("%d %d %s\n", &q1, &q2, &buf);
		if (q1 >= q2)
		{
			printf ("IMPOSSIBLE\n");
			return;
		}
		if (buf[0] == 'L')
		{
			l[q1].pb(q2);
		}
		else
		{
			r[q1].pb(q2);
		}
	}
	for (j = n; j >= 1; j--)
	{
		if (!check(j))
		{
			printf ("IMPOSSIBLE\n");
			return;
		}
	}
	dfs_print(1, n);
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	//freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
	solve();
	return 0;
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Constrained_Tree
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);
        private static Leaf[] leafs;

        private static void Main(string[] args)
        {
            int n = Next();
            int c = Next();

            var nnn = new point[c];
            for (int i = 0; i < c; i++)
            {
                nnn[i] = new point(Next(), Next(), Next());
                if (nnn[i].n >= nnn[i].m)
                {
                    writer.WriteLine("IMPOSSIBLE");
                    writer.Flush();
                    return;
                }
            }

            Array.Sort(nnn, nnn[0]);

            var nn = new List<point>();
            nn.Add(nnn[0]);
            for (int i = 1; i < nnn.Length; i++)
            {
                if (nnn[i].Compare(nnn[i], nn[nn.Count - 1]) != 0)
                    nn.Add(nnn[i]);
            }

            leafs = new Leaf[n + 1];
            for (int i = 0; i < leafs.Length; i++)
            {
                leafs[i] = new Leaf {max = i, next = i + 1, parent = i, left = i};
            }
            leafs[n].next = -1;

            for (int i = nn.Count - 1; i >= 0; i--)
            {
                int maxl = -1;
                int maxr = -1;
                int minr = int.MaxValue;
                int leftl = -1;
                int rigthl = -1;
                int lastgood = i;
                for (int j = i; j >= 0; j--)
                {
                    if (nn[j].n != nn[i].n)
                        break;

                    int pi = Parent(nn[j].m);
                    if (nn[j].k > 0)
                    {
                        if (maxr < leafs[pi].max)
                        {
                            maxr = leafs[pi].max;
                            rigthl = leafs[pi].left;
                        }

                        minr = Math.Min(minr, pi);
                    }
                    else
                    {
                        if (maxl < leafs[pi].max)
                        {
                            maxl = leafs[pi].max;
                            leftl = leafs[pi].left;
                        }
                    }
                    lastgood = j;
                }

                for (; i >= lastgood; i--)
                {
                    int pi = Parent(nn[i].m);
                    if (pi != nn[i].n)
                        leafs[pi].parent = nn[i].n;
                }
                i++;

                if (minr <= maxl)
                {
                    writer.WriteLine("IMPOSSIBLE");
                    writer.Flush();
                    return;
                }

                leafs[nn[i].n].max = Math.Max(maxr, maxl);

                for (int j = nn[i].n + 1; j <= leafs[nn[i].n].max; j++)
                {
                    if (Parent(j) != nn[i].n)
                    {
                        leafs[j].parent = nn[i].n;
                    }
                    else
                    {
                        j = leafs[j].max;
                    }
                }

                if (maxl != -1)
                {
                    leafs[nn[i].n - 1].next = leafs[nn[i].n].next;
                    leafs[nn[i].n].next = leafs[leftl].next;
                    leafs[leftl].next = nn[i].n;
                }

                if (maxr != -1)
                    leafs[nn[i].n].left = rigthl;
            }

            int index = leafs[0].next;
            while (index != -1)
            {
                writer.Write(index);
                writer.Write(' ');

                index = leafs[index].next;
            }
            writer.Flush();
        }

        private static int Parent(int index)
        {
            if (leafs[index].parent == index)
                return index;
            return leafs[index].parent = Parent(leafs[index].parent);
        }

        private static int Next()
        {
            int c;
            do
            {
                c = reader.Read();
                if (c == 'L')
                    return -1;
                if (c == 'R')
                    return 1;
            } while (c < '0' || c > '9');
            int res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }

        #region Nested type: Leaf

        private struct Leaf
        {
            public int left;
            public int max;
            public int next;
            public int parent;
        }

        #endregion

        #region Nested type: point

        private class point : IComparer<point>
        {
            public readonly int k;
            public readonly int m;
            public readonly int n;

            public point(int n, int m, int k)
            {
                this.n = n;
                this.m = m;
                this.k = k;
            }

            #region IComparer<point> Members

            public int Compare(point x, point y)
            {
                int c = x.n.CompareTo(y.n);
                if (c == 0)
                {
                    c = x.k.CompareTo(y.k);
                    if (c == 0)
                        c = x.m.CompareTo(y.m);
                }
                return c;
            }

            #endregion
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Constrained_Tree
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);
        private static Leaf[] leafs;

        private static void Main(string[] args)
        {
            int n = Next();
            int c = Next();

            var nnn = new point[c];
            for (int i = 0; i < c; i++)
            {
                nnn[i] = new point(Next(), Next(), Next());
                if (nnn[i].n >= nnn[i].m)
                {
                    writer.WriteLine("IMPOSSIBLE");
                    writer.Flush();
                    return;
                }
            }

            Array.Sort(nnn, nnn[0]);

            var nn = new List<point>(c) {nnn[0]};
            for (int i = 1; i < nnn.Length; i++)
            {
                if (nnn[i].Compare(nnn[i], nn[nn.Count - 1]) != 0)
                    nn.Add(nnn[i]);
            }

            leafs = new Leaf[n + 1];
            for (int i = 0; i < leafs.Length; i++)
            {
                leafs[i] = new Leaf {max = i, next = i + 1, parent = i, left = i};
            }
            leafs[n].next = -1;

            for (int i = nn.Count - 1; i >= 0; i--)
            {
                int maxl = -1;
                int maxr = -1;
                int minr = int.MaxValue;
                int leftl = -1;
                int rigthl = -1;
                int lastgood = i;
                for (int j = i; j >= 0; j--)
                {
                    if (nn[j].n != nn[i].n)
                        break;

                    int pi = Parent(nn[j].m);
                    if (nn[j].k > 0)
                    {
                        if (maxr < leafs[pi].max)
                        {
                            maxr = leafs[pi].max;
                            rigthl = leafs[pi].left;
                        }

                        minr = Math.Min(minr, pi);
                    }
                    else
                    {
                        if (maxl < leafs[pi].max)
                        {
                            maxl = leafs[pi].max;
                            leftl = leafs[pi].left;
                        }
                    }
                    lastgood = j;
                }

                for (; i >= lastgood; i--)
                {
                    int pi = Parent(nn[i].m);
                    if (pi != nn[i].n)
                        leafs[pi].parent = nn[i].n;
                }
                i++;

                if (minr <= maxl)
                {
                    writer.WriteLine("IMPOSSIBLE");
                    writer.Flush();
                    return;
                }

                leafs[nn[i].n].max = Math.Max(maxr, maxl);

                for (int j = nn[i].n + 1; j <= leafs[nn[i].n].max; j++)
                {
                    if (Parent(j) != nn[i].n)
                    {
                        leafs[j].parent = nn[i].n;
                    }
                    else
                    {
                        j = leafs[j].max;
                    }
                }

                if (maxl != -1)
                {
                    leafs[nn[i].n - 1].next = leafs[nn[i].n].next;
                    leafs[nn[i].n].next = leafs[leftl].next;
                    leafs[leftl].next = nn[i].n;
                }

                if (maxr != -1)
                    leafs[nn[i].n].left = rigthl;
            }

            int index = leafs[0].next;
            while (index != -1)
            {
                writer.Write(index);
                writer.Write(' ');

                index = leafs[index].next;
            }
            writer.Flush();
        }

        private static int Parent(int index)
        {
            if (leafs[index].parent == index)
                return index;
            return leafs[index].parent = Parent(leafs[index].parent);
        }

        private static int Next()
        {
            int c;
            do
            {
                c = reader.Read();
                if (c == 'L')
                    return -1;
                if (c == 'R')
                    return 1;
            } while (c < '0' || c > '9');
            int res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }

        #region Nested type: Leaf

        private struct Leaf
        {
            public int left;
            public int max;
            public int next;
            public int parent;
        }

        #endregion

        #region Nested type: point

        private struct point : IComparer<point>
        {
            public readonly int k;
            public readonly int m;
            public readonly int n;

            public point(int n, int m, int k)
            {
                this.n = n;
                this.m = m;
                this.k = k;
            }

            #region IComparer<point> Members

            public int Compare(point x, point y)
            {
                int c = x.n.CompareTo(y.n);
                if (c == 0)
                {
                    c = x.m.CompareTo(y.m);
                    if (c == 0)
                        c = x.k.CompareTo(y.k);
                }
                return c;
            }

            #endregion
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Constrained_Tree
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);
        private static Leaf[] leafs;

        private static void Main(string[] args)
        {
            int n = Next();
            int c = Next();

            var nn = new point[c];
            for (int i = 0; i < c; i++)
            {
                nn[i] = new point(Next(), Next(), Next());
                if (nn[i].n >= nn[i].m)
                {
                    writer.WriteLine("IMPOSSIBLE");
                    writer.Flush();
                    return;
                }
            }

            Array.Sort(nn, nn[0]);

            var list = new List<point>();
            list.Add(nn[0]);
            for (int i = 1; i < nn.Length; i++)
            {
                if (nn[i].Compare(nn[i], list[list.Count - 1]) != 0)
                    list.Add(nn[i]);
            }
            nn = list.ToArray();

            leafs = new Leaf[n + 1];
            for (int i = 0; i < leafs.Length; i++)
            {
                leafs[i] = new Leaf {max = i, next = i + 1, parent = i, left = i};
            }
            leafs[n].next = -1;

            for (int i = nn.Length - 1; i >= 0; i--)
            {
                int maxl = -1;
                int maxr = -1;
                int minr = int.MaxValue;
                int leftl = -1;
                int rigthl = -1;
                int lastgood = i;
                for (int j = i; j >= 0; j--)
                {
                    if (nn[j].n != nn[i].n)
                        break;

                    int pi = Parent(nn[j].m);
                    if (nn[j].k > 0)
                    {
                        if (maxr < leafs[pi].max)
                        {
                            maxr = leafs[pi].max;
                            rigthl = leafs[pi].left;
                        }

                        minr = Math.Min(minr, pi);
                    }
                    else
                    {
                        if (maxl < leafs[pi].max)
                        {
                            maxl = leafs[pi].max;
                            leftl = leafs[pi].left;
                        }
                    }

                    //leafs[pi].parent = nn[i].n;
                    lastgood = j;
                }

                for (; i>=lastgood; i--)
                {
                    int pi = Parent(nn[i].m);
                    if (pi != nn[i].n)
                        leafs[pi].parent = nn[i].n;
                }
                i++;

                if (minr <= maxl)
                {
                    writer.WriteLine("IMPOSSIBLE");
                    writer.Flush();
                    return;
                }

                leafs[nn[i].n].max = Math.Max(maxr, maxl);

                for (int j = nn[i].n + 1; j <= leafs[nn[i].n].max; j++)
                {
                    if (Parent(j) != nn[i].n)
                    {
                        leafs[j].parent = nn[i].n;
                    }
                    else
                    {
                        j = leafs[j].max;
                    }
                }

                if (maxl != -1)
                {
                    leafs[nn[i].n - 1].next = leafs[nn[i].n].next;
                    leafs[nn[i].n].next = leafs[leftl].next;
                    leafs[leftl].next = nn[i].n;
                }

                if (maxr != -1)
                    leafs[nn[i].n].left = rigthl;
            }

            int index = leafs[0].next;
            while (index != -1)
            {
                writer.Write(index);
                writer.Write(' ');

                index = leafs[index].next;
            }
            writer.Flush();
        }

        private static int Parent(int index)
        {
            if (leafs[index].parent == index)
                return index;
            return leafs[index].parent = Parent(leafs[index].parent);
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == 'L')
                    return -1;
                if (c == 'R')
                    return 1;
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }

        #region Nested type: Leaf

        private struct Leaf
        {
            public int left;
            public int max;
            public int next;
            public int parent;
        }

        #endregion

        #region Nested type: point

        private class point : IComparer<point>
        {
            public readonly int k;
            public readonly int m;
            public readonly int n;

            public point(int n, int m, int k)
            {
                this.n = n;
                this.m = m;
                this.k = k;
            }

            #region IComparer<point> Members

            public int Compare(point x, point y)
            {
                int c = x.n.CompareTo(y.n);
                if (c == 0)
                {
                    c = x.k.CompareTo(y.k);
                    if (c == 0)
                        c = x.m.CompareTo(y.m);
                }
                return c;
            }

            #endregion
        }

        #endregion
    }
}