func_code_string: #include <bits/stdc++.h>   using namespace std;   class Solver {    public:     void solve() {       cin >> n;       long long sign = 1;       long long C = n;       long long three_to_i = 1;       for (long long i = 1; i <= n; i++) {         long long term = 2LL * (sign < 0 ? sign + mod : sign) * C;         term %= mod;         term *= powmod(3, n * n - n * i + i);         term %= mod;         ans += term;         ans %= mod;         sign = -sign;         C = next_C(n, i + 1LL, C);       }       C = 1;       sign = -1;       for (long long i = 0; i < n; i++) {         long long term = C;         term *= 3 * (sign < 0 ? sign + mod : sign);         term %= mod;         term *= calc_term(i, three_to_i);         term %= mod;         ans += term;         ans %= mod;         three_to_i *= 3LL;         three_to_i %= mod;         C = next_C(n, i + 1LL, C);         sign = -sign;       }       cout << ans << endl;     }     long long calc_term(long long i, long long three_to_i) {       long long k1 = 1 - three_to_i;       if (k1 < 0) k1 += mod;       long long ans = powmod(k1, n);       long long a2 = powmod(mod - three_to_i, n);       ans = ans - a2;       if (ans < 0) ans += mod;       return ans;     }     long long powmod(long long x, long long n) {       n %= (mod - 1LL);       long long base = x;       long long ans = 1;       while (n) {         if (1LL & n) {           ans *= base;           ans %= mod;         }         base *= base;         base %= mod;         n >>= 1;       }       return ans;     }     long long next_C(long long n, long long k, long long cnk_1) {       if (k == 0 || k == n) return 1LL;       cnk_1 *= n - k + 1LL;       cnk_1 %= mod;       cnk_1 *= powmod(k, mod - 2);       return cnk_1 % mod;     }     long long mod = 998244353;     long long n;     long long ans = 0;   };   int main() {     Solver sol;     sol.solve();     return 0;   }   