import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { static int H = 60; static int H1; static int W = 25; static int T = 1000; static int[][] hp0, hp, pw; static int[] ap, ap5; static int score, cx, lv, sum, t; static List ok; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); H1 = H - 1; hp0 = new int[W][H]; hp = new int[W][H]; pw = new int[W][H]; ap = new int[W]; ap5 = new int[W]; score = 0; cx = 12; lv = 1; sum = 0; ok = new ArrayList<>(3); solve(br); } static int solve(BufferedReader br) throws Exception { for (t = 0; t < T; t++) { int n = Integer.parseInt(br.readLine()); if (n == -1) { return score; } // 1マス下がる for (int y = 0; y < H1; y++) { for (int x = 0; x < W; x++) { hp0[x][y] = hp0[x][y + 1]; hp[x][y] = hp[x][y + 1]; pw[x][y] = pw[x][y + 1]; } } for (int x = 0; x < W; x++) { hp0[x][H1] = 0; hp[x][H1] = 0; pw[x][H1] = 0; } // 敵機出現 for (int i = 0; i < n; i++) { String[] sa = br.readLine().split(" "); int h = Integer.parseInt(sa[0]); int p = Integer.parseInt(sa[1]); int x = Integer.parseInt(sa[2]); hp0[x][H1] = h; hp[x][H1] = h; pw[x][H1] = p; ap[x]++; } for (int x = 0; x < W; x++) { int val = 0; for (int x2 = x - 2; x2 <= x + 2; x2++) { int x3 = x2; if (x3 < 0) x3 += W; if (x3 >= W) x3 -= W; val += ap[x3]; } ap5[x] = val; } // 自機移動 char dir = getMoveDir(); if (dir == 'L') { cx = left(cx); } else if (dir == 'R') { cx = right(cx); } System.out.println(dir); // 攻撃 for (int y = 1; y < H; y++) { if (hp[cx][y] > 0) { hp[cx][y] -= lv; if (hp[cx][y] <= 0) { hp[cx][y] = 0; score += hp0[cx][y]; sum += pw[cx][y]; lv = 1 + sum / 100; } break; } } } return score; } static char getMoveDir() { ok.clear(); int lx = left(cx); int rx = right(cx); if (hp[lx][0] == 0 && hp[lx][1] <= lv) { ok.add('L'); } if (hp[rx][0] == 0 && hp[rx][1] <= lv) { ok.add('R'); } if (hp[cx][1] <= lv) { ok.add('S'); } if (ok.isEmpty()) { return 'S'; } if (ok.size() == 1) { return ok.get(0); } Teki[] arr = new Teki[W]; int cnt = 0; for (int x = 0; x < W; x++) { for (int y = 1; y < H; y++) { if (hp[x][y] > 0) { arr[x] = makeTarget(x, y); if (arr[x] != null) { cnt++; } break; } } } if (cnt == 0) { int max = 0; int maxidx = 0; for (int x = 0; x < W; x++) { if (ap5[x] > max) { max = ap5[x]; maxidx = x; } } if (maxidx == cx && ok.contains('S')) { return 'S'; } char ret = near(cx, maxidx); if (ok.contains(ret)) { return ret; } return 'S'; } else { Teki best = null; for (int x = 0; x < W; x++) { Teki o = arr[x]; if (o != null) { // TODO if (t < 500) { o.val = (double) o.pw / o.turn; } else { o.val = (double) o.hp0 / o.turn; } if (best == null || o.val > best.val) { best = o; } } } return best.dir; } } static Teki makeTarget(int x, int y) { int dx = W; char dir = 'S'; if (x == cx) { dx = 0; } else { if (ok.contains('L')) { if (x <= cx) { dx = cx - x - 1; } else { dx = cx + W - x - 1; } dir = 'L'; } if (ok.contains('R')) { int dx2 = 0; if (cx <= x) { dx2 = x - cx - 1; } else { dx2 = x + W - cx - 1; } if (dx2 < dx) { dx = dx2; dir = 'R'; } } } int dy = y - dx; int cnt = (hp[x][y] + lv - 1) / lv; if (dy < cnt) { return null; } Teki ret = new Teki(x, y); ret.dir = dir; ret.turn = dx + cnt; return ret; } static boolean can(int x, int y) { int dx = W; if (x == cx) { dx = 0; } else { if (ok.contains('L')) { if (x <= cx) { dx = cx - x - 1; } else { dx = cx + W - x - 1; } } if (ok.contains('R')) { if (cx <= x) { dx = Math.min(dx, x - cx - 1); } else { dx = Math.min(dx, x + W - cx - 1); } } } int dy = y - dx; int cnt = (hp[x][y] + lv - 1) / lv; return dy >= cnt; } static char near(int from, int to) { int dxl = from - to; if (dxl < 0) dxl += W; int dxr = to - from; if (dxr < 0) dxr += W; if (dxl <= dxr) { return 'L'; } else { return 'R'; } } static int left(int x) { x--; if (x == -1) { x = W - 1; } return x; } static int right(int x) { x++; if (x == W) { x = 0; } return x; } static class Teki { int x, y, hp0, hp, pw; int turn; char dir; double val; public Teki(int x, int y) { this.x = x; this.y = y; this.hp0 = Main.hp0[x][y]; this.hp = Main.hp[x][y]; this.pw = Main.pw[x][y]; } } }