Link to this code:
https://cses.fi/paste/e33e9f9524b4c16be50324/#include <bits/stdc++.h>
using namespace std;
#define in(a) \
for (auto &x : a) \
cin >> x;
#define out(a) \
for (auto x : a) \
cout << x << " ";
#define pb push_back
#define int long long
typedef vector<int> vi;
typedef pair<int, int> pii;
void solve() {
int n;
cin >> n;
int a = 1, b = 1;
int mod = 1e9 + 7;
while (--n) {
int na = (2 * a + b) % mod;
int nb = (4 * b + a) % mod;
a = na;
b = nb;
// cout << (a + b) % mod << '\n';
}
cout << (a + b) % mod << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}