#include<stdio.h>
#include<string.h>
int main(){
int T;
scanf("%d",&T);
getchar();
while(T--){
char a[100]={""};
gets(a);
int i;
for(i=0;i<strlen(a);i++)
{
if((a[i]=='S'||a[i]=='s')&&(a[i+1]=='S'||a[i+1]=='s')&&(a[i+2]=='R'||a[i+2]=='r'))
{
printf("***");
i+=2;
}
else if((a[i]=='A'||a[i]=='a')&&(a[i+1]=='F'||a[i+1]=='f')&&(a[i+2]=='R'||a[i+2]=='r')&&(a[i+3]=='I'||a[i+3]=='i')&&(a[i+4]=='C'||a[i+4]=='c')&&(a[i+5]=='A'||a[i+5]=='a'))
{
printf("AFRICA");
i+=5;
}
else
printf("%c",a[i]);
}
printf("\n");
}
return 0;
}