#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;
int main()
{
int t;
char question[320];
bool x[26]={false};
int i;
scanf("%d",&t);
while(t--)
{
gets(question);
for(i=0;i<(int)strlen(question);++i)
{
if(isalpha(question[i]))
{
if(islower(question[i]))
x[question[i]-97]=true;
else
x[question[i]-65]=true;
}
}
bool flag=true;
for(i=0;i<26;++i)
{
if(x[i]==false)
{
printf("%c\n",i+65);
flag=false;
break;
}
}
if(flag) printf("~\n");
}
return 0;
}
I2luY2x1ZGU8Y3N0ZGlvPgojaW5jbHVkZTxjc3RyaW5nPgojaW5jbHVkZTxjY3R5cGU+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCkKewogICAgaW50IHQ7CiAgICBjaGFyIHF1ZXN0aW9uWzMyMF07CiAgICBib29sIHhbMjZdPXtmYWxzZX07CiAgICBpbnQgaTsKICAgIHNjYW5mKCIlZCIsJnQpOwogICAgd2hpbGUodC0tKQogICAgewogICAgICAgIGdldHMocXVlc3Rpb24pOwogICAgICAgIGZvcihpPTA7aTwoaW50KXN0cmxlbihxdWVzdGlvbik7KytpKQogICAgICAgIHsKICAgICAgICAgICAgaWYoaXNhbHBoYShxdWVzdGlvbltpXSkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKGlzbG93ZXIocXVlc3Rpb25baV0pKQogICAgICAgICAgICAgICAgICAgIHhbcXVlc3Rpb25baV0tOTddPXRydWU7CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgeFtxdWVzdGlvbltpXS02NV09dHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBib29sIGZsYWc9dHJ1ZTsKICAgICAgICBmb3IoaT0wO2k8MjY7KytpKQogICAgICAgIHsKICAgICAgICAgICAgaWYoeFtpXT09ZmFsc2UpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHByaW50ZigiJWNcbiIsaSs2NSk7CiAgICAgICAgICAgICAgICBmbGFnPWZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYoZmxhZykgcHJpbnRmKCJ+XG4iKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==