import java.util.Arrays; import java.util.Scanner; public final class Main { private static final int maxTurn = 1000; private static final int Y = 60; private static final int X = 25; public static final void main(final String[] args) { new Main().run(); } private void run() { Enemy[][] board = new Enemy[Y + 1][X]; int playerX = 12; int sumP = 0; int score = 0; try (final Scanner in = new Scanner(System.in)) { for (int turn = 0; turn < maxTurn; turn++) { StringBuilder res = new StringBuilder(); for (int x = 0; x < X; x++) { for (int y = 0; y < Y; y++) { board[y][x] = board[y + 1][x]; } board[Y][x] = null; } int n = in.nextInt(); if (n < 0) { break; } for (int i = 0; i < n; i++) { int h = in.nextInt(); int p = in.nextInt(); int x = in.nextInt(); board[Y - 1][x] = new Enemy(h, p); } if (isUnderAttack(board, playerX)) { res.append("S").append("\n"); } else { int best = -(int) 1e9; int bestP = (int) 1e9; int bestY = (int) 1e9; int bestX = (int) 1e9; for (int x = 0; x < 25; x++) { for (int y = 0; y < 60; y++) { if (board[y][x] == null) { continue; } final int turn2 = distance(playerX, x) + 1 + board[y][x].h / (1 + sumP / 100); if (turn2 < y) { if (turn2 < best) { best = turn2; bestP = board[y][x].p; bestY = y; bestX = x; } else if (turn2 == best && board[y][x].p > bestP) { best = turn2; bestP = board[y][x].p; bestY = y; bestX = x; } } break; } } res.append("#" + Utils.toString("turn", turn, "best", best)).append("\n"); res.append("#" + Utils.toString("x", bestX)).append("\n"); res.append("#" + Utils.toString("y", bestY)).append("\n"); if (board[0][playerX] == null && board[1][playerX] == null && playerX == bestX) { res.append("S").append("\n"); } else if (board[0][(playerX - 1 + 25) % 25] == null && board[1][(playerX - 1 + 25) % 25] == null && distance((playerX - 1 + 25) % 25, bestX) < distance((playerX + 1) % 25, bestX)) { res.append("L").append("\n"); playerX = (playerX - 1 + 25) % 25; } else if (board[0][(playerX + 1) % 25] == null && board[1][(playerX + 1) % 25] == null && distance((playerX - 1 + 25) % 25, bestX) > distance((playerX + 1) % 25, bestX)) { res.append("R").append("\n"); playerX = (playerX + 1) % 25; } else { if (board[0][playerX] == null && board[1][playerX] == null) { res.append("S").append("\n"); } else if (board[0][(playerX - 1 + 25) % 25] == null && board[1][(playerX - 1 + 25) % 25] == null) { res.append("L").append("\n"); playerX = (playerX - 1 + 25) % 25; } else if (board[0][(playerX + 1) % 25] == null && board[1][(playerX + 1) % 25] == null) { res.append("R").append("\n"); playerX = (playerX + 1) % 25; } } } int level = 1 + sumP / 100; for (int y = 0; y < 60; y++) { if (board[y][playerX] == null) { continue; } board[y][playerX].h -= level; if (board[y][playerX].h <= 0) { sumP += board[y][playerX].p; score += board[y][playerX].h0; res.append("#" + Utils.toString("turn", turn, "H", board[y][playerX].h, "sumP", sumP, "score", score)).append("\n"); board[y][playerX] = null; } else { res.append("#" + Utils.toString("turn", turn, "H", board[y][playerX].h, "sumP", sumP, "score", score)).append("\n"); } break; } System.out.println(res.toString().trim()); System.out.flush(); } } } private boolean isUnderAttack(Enemy[][] board, int x) { for (int y = 0; y < 60; y++) { if (board[y][x] == null) { continue; } if (board[y][x].h != board[y][x].h0) { if (board[y][x].h < y) { return true; } } break; } return false; } private int distance(int x, int x2) { return Math.min(Math.abs(x - x2), Math.abs((x + 25) - x2)); } } class Enemy { int h; int h0; int p; Enemy(int h, int p) { this.h = h; this.h0 = h; this.p = p; } } class Utils { private Utils() { } public static final void debug(Object... o) { System.err.println(toString(o)); System.err.flush(); } public static final String toString(Object... o) { return Arrays.deepToString(o); } public static boolean isValid(int v, int min, int minUpper) { return v >= min && v < minUpper; } }