var st,sta:string;
    len1,len2,i,j:longint;
    a:array[1..100] of longint;
begin
   readln(st);
   while st<>'#' do
     begin
       readln(sta);
       len1:=length(st);
       len2:=length(sta);
       for i:=1 to len1 do a[i]:=0;

       for j:=1 to len2 do
         for i:=1 to len1 do
            if sta[j]=st[i] then a[i]:=a[i]+1;

       for i:=1 to len1 do writeln(st[i],' ',a[i]);
       readln(st);
     end;
end.
/**************************************************************
	Problem: 2183
	User: admin
	Language: Pascal
	Result: Wrong Answer
****************************************************************/