input: q 14 15 24 41 43 46 58

output: a 50 49 40 23 21 18 6

What is the rule: