#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 1e6 + 5;
void slove()
{
    long long n;
    cin>>n;
    cout<<6*n*n*n*n+2<<endl;
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t = 1;
    cin>>t;
    while(t--) slove();
    return 0;
}