#include <bits/stdc++.h>
using namespace std;


bool prime(int64_t x){
    for(int del=2; del*del<=x; del++)
        if(x%del==0)return 0;
    return 1;
}


int main()
{
    int test;
    cin >> test;
    while(test--){
        int64_t d;
        cin >> d;
        int64_t del=1+d;
        while(!prime(del))del++;
        int64_t del2=del+d;
        while(!prime(del2))del2++;
        cout << del*del2 << endl;


    }
    return 0;
}
