#include <bits/stdc++.h>
using namespace std;
const int inf=1e9;
unsigned long long int pow(unsigned long long int a,unsigned long long int b){
    unsigned long long int res=1;
    while(b){
        if(b&1)res=res*a;
        a=a*a;
        b/=2;
    }
    return res;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        unsigned long long int p=pow(3,n);
        if(n>=3){
            cout<<p-6<<endl;
        }
        else cout<<p<<endl;
    }
}