Farmer John has been branding the cows with a serial number ever
since he started the farm. The new cow fad is 'RADAR' brands,
so-called because they read the same forwards and backwards (they
are palindromic). All the cows want their daughters branded in the
new RADAR style.
Each mother wants her daughter's brand to be derived from her own non-RADAR brand by summing the mother's brand and its reverse. Sometimes (e.g., 12 + 21 = 33) this yields a RADAR palindrome right away. Sometimes the process must be repeated several times until a RADAR brand emerges. Consider the brand '87' that requires four steps to convert to a RADAR brand:
Brand Reverse Sum Step 1: 87 + 78 = 165 Step 2: 165 + 561 = 726 Step 3: 726 + 627 = 1353 Step 4: 1353 + 3531 = 4884
The input file contains multiple test cases, for each test case:
* Line 1: A single integer, the mother's non-RADAR brand.
Process till EOF.
For each test case, output:
* Line 1: Two space-separated integers, respectively: the number of steps to find the RADAR brand and the ultimate RADAR brand.
USACO 2006 March