#include<iostream>
using namespace std;
int main()
{
int t,n,temp;
cin>>t;
while(t--)
{
cin>>n;
int total=1;
if(n!=0) while(n!=0) {temp=n%10; total*=temp; n/=10;}
else total=0;
cout<<total<<endl;
}
return 0;
}