#include <stdio.h>
#include <string.h>
int main(void)
{
	char str[6],str1[81];
	char *p,*q;
	int count=0;
	while(gets(str))
	{
		if(strcmp(str,"#")==0)
		{
			break;
		}
		gets(str1);
		p=str;
		q=str1;
		while(*p)
		{
			q=str1;
			count = 0;
			while(*q)
			{
				if(*p == *q)
				{
					count++;
				}
				q++;
			}
			printf("%c %d\n",*p,count);
			p++;
		}
	}
	return 0;
}
/**************************************************************
	Problem: 2183
	User: admin
	Language: C
	Result: Accepted
	Time:10 ms
	Memory:1036 kb
****************************************************************/