program madition(input,output);
var n,i,j,k,l,m,f,p,q:longint;
c:array[0..201] of char;
a,b:string;
begin
assign(input,'madition.in');
reset(input);
assign(output,'madition.out');
rewrite(output);
readln(n);
readln(a);
readln(b);
k:=length(a);
p:=length(a);
q:=length(b);
f:=0;
if length(b) <k then k:=length(b);
for i:=0 to k-1 do
begin
if (ord(a[p-i])>=ord('a'))and(ord(a[p-i])<=ord('z')) then l:=ord(a[p-i])-ord('a')+10
else l:=ord(a[p -i])-ord('0');
if (ord(b[q-i])>=ord('a'))and(ord(b[q-i])<=ord('z')) then m:=ord(b[q-i])-ord('a')+10
else m:=ord(b[q-i])-ord('0');
j:=l+m+f;
f:=0;
if j>=n then begin f:=1; j:=j mod n end;
if j<=9 then c[i]:=chr(j+ord('0'))
else c[i]:=chr(j+ord('a')-10)
end;
if k<length(a) then
begin
while (f <> 0 )and ((p-k)>0)do
begin
inc(k);
if (ord(a[p-k])=ord('a'))and(ord(a[p-k])<=ord('z')) then l:=ord(a[p-k])-ord('a')+10
else l:=ord(a[p-k])-ord('0');
j:=l+f;
if j>=n then begin f:=1;j:=j mod n end;
if j<=9 then c[k]:=chr(j+ord('0'))
else c[k]:=chr(j-10+ord('a'));
end;
if (p-k=0) and (f=1) then write('1');
for i:=1 to p- k do write(a[i]);
for i:=k to 1 do write(c[i]);
end
else
begin
while (f <> 0 )and ((p-k)>=0)do
begin
inc(k);
if (ord(b[q-k])=ord('a'))and(ord(b[q-k])<=ord('z')) then l:=ord(b[q-k])-ord('a')+10
else l:=ord(b[q-k])-ord('0');
j:=l+f;
if j>=n then begin f:=1;j:=j mod n end;
if j<=9 then c[k]:=chr(j+ord('0'))
else c[k]:=chr(j-10+ord('a'));
end ;
for i:=1 to p- k do write(a[i]);
if (q-k<0) and (f=1) then write('1');
for i:=1 to p- k do write(b[i]);
for i:=k-1 downto 0 do write(c[i]);
end;
close(input);
close(output);
end.