#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int d[]={-1,2,3,5,5,7,7,11,11,11};
int T;
string s;
signed main() {
    IOS
    cin >> T;
    while(T--) {
        cin >> s;
        cout << d[s[0]-'0'] << string(s.size()-1,'0') << '\n';
    }
    return 0;
}