using System;
using System.Collections .Generic ;
using System.Linq ;
using System.Text ;
namespace Level3
{
class Program
{
static void Main( string[ ] args)
{
string text = @"qmnjvsa nv wewc flct vprj tj tvvplvl fv xja vqildhc
xmlnvc nacyclpa fc gyt vfvw. fv wgqyp, pqq pqcs y wsq
rx qmnjvafy cgv tlvhf cw tyl aeuq fv xja tkbv cqnsqs.
lhf avawnc cv eas fuqb qvq tc yllrqr xxwa cfy. psdc uqf
avrqc gefq pyat trac xwv taa wwd dv eas flcbq. vd trawm
vupq quw x decgqcwt, yq yafl vlqs yqklhq! snafq vml
lhvqpawr nqg_vfusr_ec_wawy qp fn wgawdgf." ;
// Permute, order 43512
string permutedText = "" ;
int charAt = 0 ;
try
{
while ( true )
{
char [ ] chars = new char [ 5 ] ;
string[ ] interstitials = new string[ 5 ] ;
for ( int curIndex = 0 ; curIndex < 5 ; curIndex++ )
{
if ( Char.IsLetter ( text[ charAt] ) )
{
chars[ curIndex] = text[ charAt++ ] ;
// Take all the non-letters with it too
while ( ! Char.IsLetter ( text[ charAt] ) )
interstitials[ curIndex] += text[ charAt++ ] ;
}
}
// Now concatenate
permutedText += chars[ 3 ] + interstitials[ 0 ] + chars[ 2 ] + interstitials[ 1 ] +
chars[ 4 ] + interstitials[ 2 ] + chars[ 0 ] + interstitials[ 3 ] + chars[ 1 ] + interstitials[ 4 ] ;
}
}
catch ( Exception) { }
text = permutedText;
string[ ] rules = { "Ow" , "Aq" , "Ta" , "Sl" , "Ph" , "Ev" , "Hf" , "gg" , "dd" , "Rn" , "mm" , "Wr" , "Dp" , "cc" , "yy" , "jj" ,
"ss" , "ee" , "tt" , "xx" , "ii" , "uu" , "kk" , "bb" , } ;
foreach ( string i in rules)
{
Console.WriteLine ( "***" + i[ 1 ] ) ;
text = text.Replace ( "" + i[ 1 ] , "" + i[ 0 ] ) ;
}
// Print
int pos = 0 ;
foreach ( char c in text)
{
if ( ! Char.IsLetter ( c) )
{
Console.Write ( c) ;
continue ;
}
Console.Write ( c) ;
p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ls1XTsKICAgICAgICAgIHN0cmluZ1tdIGludGVyc3RpdGlhbHMgPSBuZXcgc3RyaW5nWzVdOwogICAgICAgICAgZm9yIChpbnQgY3VySW5kZXggPSAwOyBjdXJJbmRleCA8IDU7IGN1ckluZGV4KyspCiAgICAgICAgICB7CiAgICAgICAgICAgIGlmIChDaGFyLklzTGV0dGVyKHRleHRbY2hhckF0XSkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjaGFyc1tjdXJJbmRleF0gPSB0ZXh0W2NoYXJBdCsrXTsKICAgICAgICAgICAgICAvLyBUYWtlIGFsbCB0aGUgbm9uLWxldHRlcnMgd2l0aCBpdCB0b28KICAgICAgICAgICAgICB3aGlsZSAoIUNoYXIuSXNMZXR0ZXIodGV4dFtjaGFyQXRdKSkKICAgICAgICAgICAgICAgIGludGVyc3RpdGlhbHNbY3VySW5kZXhdICs9IHRleHRbY2hhckF0KytdOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICAvLyBOb3cgY29uY2F0ZW5hdGUKICAgICAgICAgIHBlcm11dGVkVGV4dCArPSBjaGFyc1szXSArIGludGVyc3RpdGlhbHNbMF0gKyBjaGFyc1syXSArIGludGVyc3RpdGlhbHNbMV0gKwogICAgICAgICAgICBjaGFyc1s0XSArIGludGVyc3RpdGlhbHNbMl0gKyBjaGFyc1swXSArIGludGVyc3RpdGlhbHNbM10gKyBjaGFyc1sxXSArIGludGVyc3RpdGlhbHNbNF07CiAgICAgICAgfQogICAgICB9CiAgICAgIGNhdGNoIChFeGNlcHRpb24pIHsgfQogCiAgICAgIHRleHQgPSBwZXJtdXRlZFRleHQ7CiAgICAgIHN0cmluZ1tdIHJ1bGVzID0geyAiT3ciLCAiQXEiLCAiVGEiLCAiU2wiLCAiUGgiLCAiRXYiLCAiSGYiLCAiZ2ciLCAiZGQiLCAiUm4iLCAibW0iLCAiV3IiLCAiRHAiLCAiY2MiLCAieXkiLCAiamoiLAogICAgICAgICAgICAgICAgICAgICAgICAgInNzIiwgImVlIiwgInR0IiwgInh4IiwgImlpIiwgInV1IiwgImtrIiwgImJiIiwgfTsKIAogCiAgICAgIGZvcmVhY2ggKHN0cmluZyBpIGluIHJ1bGVzKQogICAgICB7CiAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIioqKiIgKyBpWzFdKTsKICAgICAgICB0ZXh0ID0gdGV4dC5SZXBsYWNlKCIiICsgaVsxXSwgIiIgKyBpWzBdKTsKICAgICAgfQogCiAgICAgIC8vIFByaW50CiAgICAgIGludCBwb3MgPSAwOwogICAgICBmb3JlYWNoIChjaGFyIGMgaW4gdGV4dCkKICAgICAgewogICAgICAgIGlmICghQ2hhci5Jc0xldHRlcihjKSkKICAgICAgICB7CiAgICAgICAgICBDb25zb2xlLldyaXRlKGMpOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIENvbnNvbGUuV3JpdGUoYyk7CiAgICAgICAgcG9zKys7CiAgICAgICAgaWYgKHBvcyA9PSA1KQogICAgICAgIHsKICAgICAgICAgIHBvcyA9IDA7CiAgICAgICAgICAvL0NvbnNvbGUuV3JpdGUoInwiKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9Cn0=