import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Reverse reverse = new Reverse();
        while (sc.hasNextInt()) {
            int num = sc.nextInt();
            if (num == 0 || !reverse.add(num)) {
                reverse.print();
                break;
            }
        }
    }
    private static class Reverse {
        private int[] nums, reverse_nums;
        private int size;
        private Reverse() {
            nums = new int[10];
            reverse_nums = new int[10];
        }
        private boolean add(int num) {
            if (size == 10) {
                return false;
            }
            nums[size] = num;
            reverse_nums[size] = reverse(num);
            size++;
            return true;
        }
        private int reverse(int num) {
            int reverse_num = 0;
            while (num != 0) {
                reverse_num = reverse_num * 10 + num % 10;
                num /= 10;
            }
            return reverse_num;
        }
        private void print() {
            for (int i = 0; i < size; i++) {
                System.out.println(nums[i] + " " + reverse_nums[i]);
            }
        }
    }
}