const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
const inputArr = (await readline()).split(",").map(Number);
const outputArr = (await readline()).split(",").map(Number);
let res = [];
const queue = [];
let idx = 0;
for (const input of inputArr) {
queue.push(input);
while (idx < outputArr.length && queue.length > 0) {
const left = queue[0];
const right = queue[queue.length - 1];
if (outputArr[idx] == left) {
queue.shift();
res.push("L");
idx++;
}
else if (right == outputArr[idx]) {
queue.pop();
res.push("R");
idx++;
}
else break;
}
}
if (res.length < outputArr.length) return console.log("NO");
console.log(res.join(""));
})();