#!/usr/bin/perl

use strict;
use warnings;

sub readfile {
    undef $/;
    open FILE, shift;
    my $line=lc <FILE>;
    $line=~s/\s//g;
    our @sifrat;
    foreach (split '', $line) {
	push @sifrat, ord($_)-ord('a');
    }
}

sub desifriraj {
    my ($a, $b, $c, $d)=@_;
    our @sifrat;

    for (my $i=0; $i<@sifrat; $i+=2) {
	print chr(($a*$sifrat[$i]+$c*$sifrat[$i+1])%26+ord('a'));
	print chr(($b*$sifrat[$i]+$d*$sifrat[$i+1])%26+ord('a'));
    }
    print "\n";
}

readfile shift @ARGV;
desifriraj @ARGV;
