Codeforces Round #110 Problem C Cipher