#include <iostream>
#include <vector>
using namespace std;

vector<string> ans = {"2", "3", "5", "5", "7", "7", "12", "12", "12"};

void solve() {
    string str;
    cin >> str;
    int l = str.length();
    int j = str[0] - '0' - 1;
    string s(l - 1, '0');
    cout << ans[j] + s << endl;
}

int main() {
    int T;
    cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}
// 64 位输出请用 printf("%lld")