Const Fi='MESS.INP';
Fo='MESS.OUT';
Var f,g: text;
St: String;
A: array[1..255] of longint;
B: array[1..255] of string;
S,i,k: longint;
Begin
Assign(f,Fi); Reset(f);
Assign(g,Fo); Rewrite(g);
Readln(f,St);
While St[1]=#32 do Delete(St,1,1);
While St[length(St)]=#32 do Delete(St,length(St),1);
While pos(#32#32,St)<>0 do Delete(St,pos(#32#32,St),1);
s:=1;
For i:=1 to length(St) do
If St[i]=#32 then inc(s);
For i:=1 to s do
Read(f,A[i]);
k:=1;
For i:=1 to length(St) do
If St[i]<>#32 then B[k]:=B[k]+St[i]
Else inc(k);
For i:=1 to s do
Write(g,B[A[i]],' ');
Close(f);
Close(g);
End.