program rsa;
const MaxL=100;
var N, d, L , i:int64;
    messaggio : array [0..maxL] of int64;
    plaintext : array [0..maxL] of char;
    
function fast_pow (base:int64; esp:int64; modd:int64) :int64;
var meta :int64;
begin
 if esp = 0 then  fast_pow:=1
 else
    if esp = 1 then fast_pow:= base mod modd
    else
     begin
       meta := fast_pow(base, esp div 2, modd);	
       if esp mod 2 =0 then fast_pow:= (meta*meta) mod modd
                                  else  fast_pow:= (meta*meta * base) mod modd;
	end;
end;
procedure decifra (N :int64; d:int64;L:int64; var messaggio :array of int64 ;plaintext:array of char);
var i:int64;
    begin    
      plaintext[L]:=char(0);
      for  i:=0  to L-1 do plaintext[i]:=char(fast_pow(messaggio[i], d, N));
      for i:=0 to L -1 do write(plaintext[i]);
    end;

    
begin
  readln (N,d,L);
  for i:=0 to L-1 do read(messaggio[i]);readln;
  decifra(N,d,L,messaggio,plaintext);
end.
