407152: GYM102697 123 Affine Cipher

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

123. Affine Ciphertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
This problem is worth 25 points.

You're trying to come up with a good Codeforces username. You want to use something similar to your real name, but not exactly your real name, to not release too much info about yourself online. Thus, you decide to encode your username using an Affine cipher.

An affine cipher uses a key of two values: $$$a$$$ and $$$b$$$. Given a letter $$$l$$$, you first convert it into it's "character code", for example, "a" would become $$$0$$$, "b" would become $$$1$$$, etc. We'll call this $$$x$$$. Then, you calculate the value of $$$a$$$$$$x$$$ + $$$b$$$ mod $$$26$$$, and reverse the character code mapping that you used previously, to convert the answer back into a letter. The affine cipher runs this process on all letters (not spaces) in a given string.

For example, let's use the letter $$$c$$$, and a key of $$$a$$$ = $$$15$$$, and $$$b$$$ = $$$5$$$. $$$c$$$ has a character code of $$$2$$$. Then, the encoded character has a character code of $$$15$$$*$$$2$$$ + $$$5$$$ mod $$$26$$$ = $$$35$$$ mod $$$26$$$ = $$$9$$$. Thus, the encoded character is $$$j$$$.

Input

The first line of input contains two space-separated integers $$$a$$$ and $$$b$$$: the affine cipher's key, as described above. The second line of input consists of a string consisting only of lowercase characters and spaces.

Output

Output the input string, encoded using the affine cipher as described above.

ExamplesInput
7 5
xavier
Output
kfwjhu
Input
11 1
coderams club
Output
xzitgbdr xsnm

加入题单

算法标签: