Source code in C++.
-----------------------------
#include<bits/stdc++.h>
using namespace std;
int main()
{
char str[109],str1[109];
char arr[109],arr1[109];
int n;
scanf("%d ",&n);
for(int k=1; k<=n; k++)
{
gets(str);
gets(str1);
int l=0;
for(int i=0; i<strlen(str); i++)
{
if(str[i]>='A'&&str[i]<='Z')
{
str[i]=str[i]+' ';
}
if(str[i]!=' ')
{
arr[l]=str[i];
l++;
}
}
int m=0;
for(int i=0; i<strlen(str1); i++)
{
if(str1[i]>='A'&&str1[i]<='Z')
str1[i]=str1[i]+' ';
if(str1[i]!=' ')
{
arr1[m]=str1[i];
m++;
}
}
sort(arr,arr+l);
sort(arr1,arr1+m);
bool ok= true;
if(l==m)
{
if(ok)
printf("Case %d: Yes\n",k);
else
printf("Case %d: No\n",k);
}
else
printf("Case %d: No\n",k);
}
return 0;
}