Xenia the vigorous detective faced n (n ≥ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right. 

Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can pass the note to one of his neighbours in the row. In other words, if this spy's number is x, he can pass the note to another spy, either x - 1 or x + 1 (if x = 1 or x = n, then the spy has only one neighbour). Also during a step the spy can keep a note and not pass it to anyone.

But nothing is that easy. During m steps Xenia watches some spies attentively. Specifically, during step t_{i} (steps are numbered from 1) Xenia watches spies numbers l_{i}, l_{i} + 1, l_{i} + 2, ..., r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). Of course, if during some step a spy is watched, he can't do anything: neither give the note nor take it from some other spy. Otherwise, Xenia reveals the spies' cunning plot. Nevertheless, if the spy at the current step keeps the note, Xenia sees nothing suspicious even if she watches him.

You've got s and f. Also, you have the steps during which Xenia watches spies and which spies she is going to watch during each step. Find the best way the spies should act in order to pass the note from spy s to spy f as quickly as possible (in the minimum number of steps).


-----Input-----

The first line contains four integers n, m, s and f (1 ≤ n, m ≤ 10^5; 1 ≤ s, f ≤ n; s ≠ f; n ≥ 2). Each of the following m lines contains three integers t_{i}, l_{i}, r_{i} (1 ≤ t_{i} ≤ 10^9, 1 ≤ l_{i} ≤ r_{i} ≤ n). It is guaranteed that t_1 < t_2 < t_3 < ... < t_{m}.


-----Output-----

Print k characters in a line: the i-th character in the line must represent the spies' actions on step i. If on step i the spy with the note must pass the note to the spy with a lesser number, the i-th character should equal "L". If on step i the spy with the note must pass it to the spy with a larger number, the i-th character must equal "R". If the spy must keep the note at the i-th step, the i-th character must equal "X".

As a result of applying the printed sequence of actions spy s must pass the note to spy f. The number of printed characters k must be as small as possible. Xenia must not catch the spies passing the note.

If there are miltiple optimal solutions, you can print any of them. It is guaranteed that the answer exists.


-----Examples-----
Input
3 5 1 3
1 1 2
2 2 3
3 3 3
4 1 1
10 1 3

Output
XXRR

Difficulty: interview

Starter code:

Solutions:
import sys
n,m,s,f=list(map(int,sys.stdin.readline().split()))
L=[]
R=[]
T=[]
for i in range(m):
    t,l,r=list(map(int,sys.stdin.readline().split()))
    T.append(t)
    L.append(l)
    R.append(r)

if(f>s):
    i=s
    step=1
    ind=0
    Ans=""
    while(i!=f):
        if(ind>=m or T[ind]!=step):
            Ans+="R"
            i+=1
        else:
            if((i>=L[ind] and i<=R[ind]) or (i+1>=L[ind] and i+1<=R[ind])):
                Ans+="X"
            else:
                Ans+="R"
                i+=1
            ind+=1
        step+=1
else:
    i=s
    step=1
    ind=0
    Ans=""
    while(i!=f):
        if(ind>=m or T[ind]!=step):
            Ans+="L"
            i-=1
        else:
            if((i>=L[ind] and i<=R[ind]) or (i-1>=L[ind] and i-1<=R[ind])):
                Ans+="X"
            else:
                Ans+="L"
                i-=1
            ind+=1
        step+=1
sys.stdout.write(Ans+"\n")


n,m,s,f = map (int, input().split())
watch = {}
for i in range (m):
  t,l,r = map (int, input().split())
  watch[t] = (l,r)
cur = s
move,symbol = (1,'R') if s < f else (-1,'L')
step = 1
while cur != f:
  if step in watch:
    l,r = watch[step]
    if (l <= cur <= r or
        l <= (cur+move) <= r):
      print ('X',end='')
    else:
      cur += move
      print (symbol,end='')
  else:
    cur += move
    print (symbol,end='')
  step += 1


n, m, s, f = [int(x) for x in input().split()]
now = 1
d = 1 if f > s else -1
step = 'R' if d == 1 else 'L'

ret = ""

for _ in range(m):
    t, l, r = [int(x) for x in input().split()]
    if t > now:
        flag = False
        while t > now:
            s += d
            ret += step
            now += 1
            if s == f:
                flag = True
                break
        if flag:
            break
    if l <= s <= r or l <= s+d <= r:
        ret += 'X'
    else:
        ret += step
        s += d
    if s == f:
        break
    now += 1

while s != f:
    s += d
    ret += step

print(ret)



def __starting_point():
    inp = input()
    arr = inp.split(' ')
    n = int(arr[0])
    m = int(arr[1])
    s = int(arr[2])
    f = int(arr[3])
    ans = ""
    ch = 'L'
    inc = -1
    if s<f:
        ch='R'
        inc = 1
    tm = 1
    done = False
    for i in range(m):
        inp = input()
        if done:
            continue
        arr = inp.split(' ')
        ct = int(arr[0])
        l = int(arr[1])
        r = int(arr[2])
        while ct!=tm:
            ans+=ch
            tm+=1
            s+=inc
            if s==f:
                break
        if s!=f and (((s+inc)>=l and (s+inc)<=r)or((s>=l)and(s<=r))):
            ans += 'X'
        elif s!=f:
            ans += ch
            s += inc
        tm+=1
        if s==f:
            done = True
    while s!=f:
        s+=inc
        ans+=ch
    print(ans)
        

__starting_point()

n,m,s,f=list(map(int,input().split()));
d={};
for i in range(m):
    t,l,r=list(map(int,input().split()));
    d[t]=[l,r];
ans="";
for i in range(1,n+m):
    if(s==f):
        print(ans);
        return;
    t=-1;
    if(f<s):
        t=s-1;
    else:
        t=s+1;
    if i in d:
        if((d[i][0]<=s and s<=d[i][1]) or (d[i][0]<=t and t<=d[i][1])):
            t=-1;
    if(t==-1):
        ans+="X";
    else:
        if(f<s):
            ans+="L";
        else:
            ans+="R";
        s=t;
print(ans);



n,m,s,f=list(map(int,input().split()))
t={}
step=1
ans=''
if s<f:sig='R'
else :sig='L'
for i in range(m):
    t0,l0,r0=list(map(int,input().split()))
    t[t0]=[l0,r0]

for i in range(1,n+m+1):
    if s<f:
            u=s+1
            
    else:u=s-1
    if i in t:
      
        if (t[i][0]<=s<=t[i][1])or(t[i][0]<=u<=t[i][1]):
            ans+='X'
        else:
            ans+=sig
            s=u
        
    else :
        ans+=sig
        s=u
    if s==f:break

print(ans)    


R = lambda: list(map(int, input().split()))
n, m, s, f = R()

if s < f:
  d = 1
  c = 'R'
else:
  d = -1
  c = 'L'
  
res = ""
i = 1
j = s
t, l, r = R()
k = 1
while j != f:
  if i > t and k < m:
    t, l, r = R()
    k += 1
  if i == t and (l <= j <= r or l <= j + d <= r):
    res += 'X'
  else:
    res += c
    j += d
  i += 1
    
print(res)  


n, m, s, f = list(map(int, input().split()))

ans, p = '', 1
if s < f:
    for i in range(m):
        t, l, r = list(map(int, input().split()))
        if t > p:
            if t - p < f - s:
                ans += 'R' * (t - p)
                s += t - p
            else:
                ans += 'R' * (f - s)
                s = f
                break
        p = t + 1
        if s + 1 < l or s > r:
            ans += 'R'
            s += 1
            if s == f: break
        else: ans += 'X'
else:
    for i in range(m):
        t, l, r = list(map(int, input().split()))
        if t > p:
            if t - p < s - f:
                ans += 'L' * (t - p)
                s -= t - p
            else:
                ans += 'L' * (s - f)
                s = f
                break
        p = t + 1
        if s < l or s - 1 > r:
            ans += 'L'
            s -= 1
            if s == f: break
        else: ans += 'X'
print(ans + ('R' * (f - s) if f > s else 'L' * (s - f)))


import sys
n,m,s,f=list(map(int,sys.stdin.readline().split()))
L=[]
R=[]
T=[]
for i in range(m):
    t,l,r=list(map(int,sys.stdin.readline().split()))
    T.append(t)
    L.append(l)
    R.append(r)

if(f>s):
    i=s
    step=1
    ind=0
    Ans=""
    while(i!=f):
        if(ind>=m or T[ind]!=step):
            Ans+="R"
            i+=1
        else:
            if((i>=L[ind] and i<=R[ind]) or (i+1>=L[ind] and i+1<=R[ind])):
                Ans+="X"
            else:
                Ans+="R"
                i+=1
            ind+=1
        step+=1
else:
    i=s
    step=1
    ind=0
    Ans=""
    while(i!=f):
        if(ind>=m or T[ind]!=step):
            Ans+="L"
            i-=1
        else:
            if((i>=L[ind] and i<=R[ind]) or (i-1>=L[ind] and i-1<=R[ind])):
                Ans+="X"
            else:
                Ans+="L"
                i-=1
            ind+=1
        step+=1
sys.stdout.write(Ans+"\n")


import sys
from itertools import *
from math import *
def solve():
    n,m,s,f = map(int, input().split())
    s-=1
    f-=1
    d = {}
    for _ in range(m):
        t,l,r = map(int, input().split())
        d[t-1] = (l - 1, r - 1)
    # d = {(t - 1) : (l - 1, r - 1) for t,l,r in map(int, input().split()) for _ in range(m)}
    step = 0
    res = list()
    while s != f:
        wantnext = s + 1 if s < f else s - 1
        canmove = True
        if step in d:
            l, r = d[step]
            if (s >= l and s <= r) or (wantnext >= l and wantnext <= r): canmove = False
        if canmove:
            res.append('R' if wantnext > s else 'L')
            s = wantnext
        else: res.append('X')
        step += 1
    print(''.join(map(str, res))) #change to string at end to see if faster



if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()

import sys
from itertools import *
from math import *
def solve():
    n,m,s,f = map(int, input().split())
    s-=1
    f-=1
    d = {}
    for _ in range(m):
        t,l,r = map(int, input().split())
        d[t-1] = (l - 1, r - 1)
    # d = {(t - 1) : (l - 1, r - 1) for t,l,r in map(int, input().split()) for _ in range(m)}
    step = 0
    res = ""
    while s != f:
        wantnext = s + 1 if s < f else s - 1
        canmove = True
        if step in d:
            l, r = d[step]
            if (s >= l and s <= r) or (wantnext >= l and wantnext <= r): canmove = False
        if canmove:
            res += 'R' if wantnext > s else 'L'
            s = wantnext
        else: res += 'X'
        step += 1
    print(res)
    # print(''.join(map(str, res))) #change to string at end to see if faster



if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()

"""http://codeforces.com/problemset/problem/342/B"""

def solve(s, f, t):
    res = ''
    step = 1 if s < f else -1
    i = current = 0
    while s != f:
        current += 1
        ti, l, r = t[i] if i < len(t) else (-1, -1, -1)
        if ti == current:
            i += 1
            if l <= s <= r or l <= s + step <= r:
                res += 'X'
                continue
        s += step
        res += 'R' if step > 0 else 'L'
    return res

def __starting_point():
    parse = lambda: list(map(int, input().split()))
    n, m, s, f = parse()
    l = [parse() for _ in range(m)]
    print(solve(s, f, l))

__starting_point()

n, m, s, f = list(map(int, input().split()))
c, t1 = 1, 0
ans = ""
t = 1
while s != f and t1 < m:
  t, l, r = list(map(int, input().split()))
  # print(ans)
  while t != c:
    if s < f:
      ans += "R"
      s += 1
    else:
      ans += "L"
      s -= 1
    if s == f:
      break
    c += 1
  if s < f:
    if s >= l-1 and s <= r:
      ans += "X"
    else:
      ans += "R"
      s += 1
  elif s > f:
    if s <= r+1 and s >= l:
      ans += "X"
    else:
      ans += "L"
      s -= 1
  c += 1
  t1 += 1
if s < f:
  ans += "R"*(f-s)
elif s > f:
  ans += "L"*(s-f)
print(ans)
















R = lambda: map(int, input().split())
n, m, s, f = R()

if s < f:
  d = 1
  c = 'R'
else:
  d = -1
  c = 'L'
  
res = ""
i = 1
j = s
t, l, r = R()
k = 1
while j != f:
  if i > t and k < m:
    t, l, r = R()
    k += 1
  if i == t and (l <= j <= r or l <= j + d <= r):
    res += 'X'
  else:
    res += c
    j += d
  i += 1
    
print(res)  

R = lambda: list(map(int, input().split()))

n, m, s, f = R()



if s < f:

  d = 1

  c = 'R'

else:

  d = -1

  c = 'L'

  

res = ""

i = 1

j = s

t, l, r = R()

k = 1

while j != f:

  if i > t and k < m:

    t, l, r = R()

    k += 1

  if i == t and (l <= j <= r or l <= j + d <= r):

    res += 'X'

  else:

    res += c

    j += d

  i += 1

    

print(res)  





# Made By Mostafa_Khaled


n,m,s,f = list(map(int,input().split()))
l = []
for i in range(m):
         k = list(map(int,input().split()))
         l.append(k)

count = 1
ans = ''
i = 0
while i<m:


    if count < l[i][0]:
        if f>s:
            ans+='R'*min(l[i][0] - count,f-s)
            s+=min(l[i][0] - count,f-s)
            count = l[i][0]

        if f<s:
            ans+='L'*min(l[i][0] - count,s-f)
            s-=min(l[i][0] - count,s-f)
            # print(min(l[i][0] - count,s-f))
            count = l[i][0]





    else:
        if l[i][1]<=s<=l[i][2]:
            ans+='X'

        else:
            if f>s:
                if l[i][1]<=s+1<=l[i][2]:
                    ans+='X'
                else:
                    ans+='R'
                    s+=1
            if f<s:
                if l[i][1]<=s-1<=l[i][2]:
                    ans+='X'
                else:
                    ans+='L'
                    s-=1
        i+=1
        count+=1
    # print(s)

    if s == f:
        break
if s!=f:
  if s<f:
    ans+='R'*(f-s)
  else:
      ans+='L'*(s-f)


print(ans)



n, m, s, f = map(int, input().split())
c, t1 = 1, 0
ans = ""
t = 1
while s != f and t1 < m:
  t, l, r = map(int, input().split())
  # print(ans)
  while t != c:
    if s < f:
      ans += "R"
      s += 1
    else:
      ans += "L"
      s -= 1
    if s == f:
      break
    c += 1
  if s < f:
    if s >= l-1 and s <= r:
      ans += "X"
    else:
      ans += "R"
      s += 1
  elif s > f:
    if s <= r+1 and s >= l:
      ans += "X"
    else:
      ans += "L"
      s -= 1
  c += 1
  t1 += 1
if s < f:
  ans += "R"*(f-s)
elif s > f:
  ans += "L"*(s-f)
print(ans)

import sys
spies, turns, note, final = list(map(int, input().split()))
if note < final:
    next = 1
else:
    next = -1
answer = []

def pass_note(current_turn, next_watch, left, right, note):
#    print(f'\n{current_turn}), next watch: {next_watch}, left: {left}, right: {right} has note: {note}, goal: {final}')
    if current_turn == next_watch:
#        print('Watched this turn')
        if note in range(left, right + 1) or note + next in range(left, right + 1):
#            if note in range(left, right + 1):
#                print(f'Im being watched')
#            else:
#                print(f'Guy to pass it to is being watched')
            return note, 'X'
#    print('Not watched, passing note to ', end='')
    if note < final:
        note += next
#        print('right')
        return note, 'R'
    else:
        note += next
#        print('left')
        return note, 'L'

current_turn = 0
for turn in range(turns):
    next_watch, left, right = list(map(int, input().split()))
    while current_turn < next_watch:
        current_turn += 1
        note, ans = pass_note(current_turn, next_watch, left, right, note)
        answer.append(ans)
        if note == final:
            print(''.join(answer))
            return

#print("ran out of turns")

while note != final:
#    print(f'Note at: {note}, goal is {final}')
    current_turn += 1
    note, ans = pass_note(current_turn, 0, -1, -1, note)
    answer.append(ans)

print(''.join(answer))


n, m, s, f = list(map(int, input().split()))
if s < f:
    d = 1
    c = 'R'
else:
    d = -1
    c = 'L'
res = ''
i, j = 1, s
t, l, r = list(map(int, input().split()))
k = 1
while j != f:
    if i > t and k < m:
        t, l, r = list(map(int, input().split()))
        k += 1
    if i == t and (l <= j <= r or l <= j + d <= r):
        res += 'X'
    else:
        res += c
        j += d
    i += 1
print(res)


n,m,s,f=list(map(int,input().split()))
p=s
d=-1
c='L'
if s<f:
    d=1
    c='R'
t=1
ts={}
ans=""
for _ in range(m):
    x,y,z=list(map(int,input().split()))
    ts[x]=(y,z)
while(p!=f):
    if t in ts:
        (l,r)=ts[t]
        if l<=p<=r or l<=p+d<=r:
            ans+='X'
        else:
            p+=d
            ans+=c
    else:
        p+=d
        ans+=c
    t+=1
print(ans)


def mi():
        return map(int, input().split())
'''
3 5 1 3
1 1 2
2 2 3
3 3 3
4 1 1
10 1 3
'''
n,m,s,f = mi()
t = [0]*m
l = [0]*m
r = [0]*m
for i in range(m):
        t[i],l[i],r[i] = mi()
curp = s
curt = 1
i = 0
a = ''
if f>s:
        a = (f-s)*'R'
else:
        a = (s-f)*'L'
while i<m and curp!=f:
        if t[i]==curt:
                if a[0]=='R' and curp+1>=l[i] and curp+1<=r[i]:
                        print ('X', end = '')
                elif a[0]=='L' and curp-1>=l[i] and curp-1<=r[i]:
                        print ('X', end = '')
                elif curp>=l[i] and curp<=r[i]:
                        print ('X', end = '')
                elif a[0]=='R':
                        curp+=1
                        print(a[0], end = '')
                else:
                        curp-=1
                        print (a[0], end = '')
                i+=1
        elif a[0]=='R':
                curp+=1
                print(a[0], end = '')
        else:
                curp-=1
                print (a[0], end = '')

        curt+=1
if f>curp:
        print ((f-curp)*'R')
elif curp>f:
        print ((curp-f)*'L')


n, m, s, f = map(int, input().split())
data = {}
for _ in range(m):
    t, l, r = map(int, input().split())
    data[t] = (l, r)
k = 1
curr = s
while curr != f:
    if k in data:
        if data[k][0] <= curr <= data[k][1]:
            print('X', end='')
        else:
            if 1 < curr < n:
                if curr > f:
                    if data[k][0] <= curr - 1 <= data[k][1]:
                        print('X', end='')
                    else:
                        print('L', end='')
                        curr -= 1
                else:
                    if data[k][0] <= curr + 1 <= data[k][1]:
                        print('X', end='')
                    else:
                        print('R', end='')
                        curr += 1
            elif curr == 1:
                if data[k][0] <= 2 <= data[k][1]:
                    print('X', end='')
                else:
                    print('R', end='')
                    curr = 2
            elif curr == n:
                if data[k][0] <= curr-1 <= data[k][1]:
                    print('X', end='')
                else:
                    print('L', end='')
                    curr -= 1
    else:
        if curr > f:
            print('L', end='')
            curr -= 1
        else:
            print('R', end='')
            curr += 1
    k += 1

# Mon Aug 12 2019 14:53:46 GMT+0300 (MSK)


n, m, s, f = map(int, input().split())
q = dict()
for i in range(m):
    t,l,r = map(int, input().split())
    q[t] = (l, r)
k=1;pos=s;
while pos!=f:
    if k in q:
        if q[k][0] <= pos <= q[k][1]:
            print('X', end='')
        else:
            if 1 < pos < n:
                if pos > f:
                    if q[k][0] <= pos-1 <= q[k][1]:
                        print('X',end='')
                    else:
                        print('L',end='')
                        pos-=1
                else:
                    if q[k][0]<=pos+1<=q[k][1]:
                        print('X',end='')
                    else:
                        print('R',end='')
                        pos+=1
            elif pos==1:
                if q[k][0]<=2<=q[k][1]:
                    print('X',end='')
                else:
                    print('R',end='')
                    pos=2
            elif pos==n:
                if q[k][0]<=pos-1<=q[k][1]:
                    print('X',end='')
                else:
                    print('L',end='')
                    pos-=1
    else:
        if pos>f:
            print('L', end='')
            pos-=1
        else:
            print('R', end='')
            pos+=1
    k+=1

n,m,s,f=map(int,input().split())
t=dict();
for i in range(m):
    t1,l1,r1=map(int,input().split())
    t[t1]=(l1,r1);
pos=s;i=1;
while(1):
    if(pos==f):
        break
    if i in t:
        if t[i][0] <= pos<=t[i][1]:
            print('X',end='')
            i+=1
            continue
        elif(f-pos>0 and t[i][0]<= pos+1<=t[i][1]):
            print('X',end='')
            i+=1
            continue
        elif(f-pos<0 and t[i][0] <= pos-1<=t[i][1]):
            print('X',end='')
            i+=1
            continue
    if(f-pos>0):
        print('R',end='')
        pos+=1
    elif(pos-f>0):
        print('L',end='')
        pos-=1
    i+=1

R = lambda: list(map(int, input().split()))
 
n, m, s, f = R()
 
 
 
if s < f:
 
  d = 1
 
  c = 'R'
 
else:
 
  d = -1
 
  c = 'L'
 
  
 
res = ""
 
i = 1
 
j = s
 
t, l, r = R()
 
k = 1
 
while j != f:
 
  if i > t and k < m:
 
    t, l, r = R()
 
    k += 1
 
  if i == t and (l <= j <= r or l <= j + d <= r):
 
    res += 'X'
 
  else:
 
    res += c
 
    j += d
 
  i += 1
 
    
 
print(res)