import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class J { class Pyramid implements Comparable { int count, base; char hilo; Pyramid(int c, int b, char h) { count = c; base = b; hilo = h; } public int compareTo(Pyramid o) { if (count == o.count) return hilo - o.hilo; return o.count - count; } public String toString() { return base + "" + hilo; } } private Pyramid[] all; private void init() { List list = new ArrayList(); int sum = 5; int b = 2; while (sum <= 1000000) { list.add(new Pyramid(sum, b, 'H')); b++; sum += b * b; } sum = 10; b = 3; while (sum <= 1000000) { list.add(new Pyramid(sum, b, 'L')); b += 2; sum += b * b; } sum = 20; b = 4; while (sum <= 1000000) { list.add(new Pyramid(sum, b, 'L')); b += 2; sum += b * b; } Collections.sort(list); all = new Pyramid[list.size()]; all = list.toArray(all); } private List[] ans; @SuppressWarnings("unchecked") private void solve() { ans = new List[1000001]; ans[0] = new ArrayList(); for (int i = 0; i < all.length; i++) { for (int j = 1000000 - all[i].count; j >= 0; j--) { if (ans[j] != null && (ans[j + all[i].count] == null || ans[j].size() + 1 <= ans[j + all[i].count].size())) { List tmp = new ArrayList(ans[j]); tmp.add(all[i]); if (ans[j + all[i].count] != null && tmp.size() == ans[j + all[i].count].size()) { for (int k = 0; k < tmp.size(); k++) { if (tmp.get(k).count > ans[j + all[i].count].get(k).count) break; if (tmp.get(k).count < ans[j + all[i].count].get(k).count) { tmp = ans[j + all[i].count]; break; } } } ans[j + all[i].count] = tmp; } } } } private void work() { init(); solve(); Scanner sc = new Scanner(System.in); int tc = 1; while (true) { int n = sc.nextInt(); if (n == 0) break; System.out.printf("Case %d:", tc++); if (ans[n] == null) System.out.println(" impossible"); else { for (Pyramid p : ans[n]) { System.out.printf(" %s", p.toString()); } System.out.println(); } } } public static void main(String[] args) { J problem = new J(); problem.work(); } }