func_code_string: #include <bits/stdc++.h>   const int N = 1e6;   const long long mod = 998244353;   const int INF = 0x7fffffff;   const int inf = 0x3f3f3f3f;   using namespace std;   void exgcd(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1;       y = 0;       return;     }     exgcd(b, a % b, y, x);     y -= a / b * x;   }   long long getlnverse(long long x, long long y) {     long long res, tmp;     exgcd(x, y, res, tmp);     return (res + y) % y;   }   long long a[N + 5];   long long cal(long long n, long long m) {     long long tmp1 = getlnverse(a[m], mod);     tmp1 = a[n] * tmp1 % mod;     long long tmp2 = getlnverse(a[n - m], mod);     return tmp1 * tmp2 % mod;   }   long long qpow(long long a, long long b) {     long long sum = 1;     while (b) {       if (b & 1) {         sum = (sum * a) % mod;         b--;       }       b /= 2;       a = a * a % mod;     }     return sum;   }   int main() {     std::ios::sync_with_stdio(false);     long long n, ans2 = 0;     cin >> n;     a[0] = 1;     for (int i = 1; i <= n; i++) {       a[i] = i * a[i - 1] % mod;     }     for (long long i = 1; i <= n; i++) {       ans2 +=           (((cal(n, i) * qpow(-1, i)) % mod) *            (qpow((qpow(3, n - i) - 1), n) + mod - qpow(3, n * (n - i))) % mod) %           mod;       ans2 = ans2 % mod;     }     long long ans1 =         (2 * (qpow(3, n * n) - qpow((mod + qpow(3, n) - 3) % mod, n) + mod)) %         mod;     cout << (3 * mod + ans1 - (3 * ans2)) % mod << endl;     return 0;   }   