On one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game.

It is well known that one month on this planet consists of n^2 days, so calendars, represented as square matrix n by n are extremely popular.

Weather conditions are even more unusual. Due to the unique composition of the atmosphere, when interacting with sunlight, every day sky takes one of three colors: blue, green or red.

To play the bingo, you need to observe the sky for one month — after each day, its cell is painted with the color of the sky in that day, that is, blue, green or red.

At the end of the month, students examine the calendar. If at least one row or column contains only cells of one color, that month is called lucky.

Let's call two colorings of calendar different, if at least one cell has different colors in them. It is easy to see that there are 3^{n ⋅ n} different colorings. How much of them are lucky? Since this number can be quite large, print it modulo 998244353.

Input

The first and only line of input contains a single integer n (1 ≤ n ≤ 1000 000) — the number of rows and columns in the calendar.

Output

Print one number — number of lucky colorings of the calendar modulo 998244353

Examples

Input

1


Output

3


Input

2


Output

63


Input

3


Output

9933

Note

In the first sample any coloring is lucky, since the only column contains cells of only one color.

In the second sample, there are a lot of lucky colorings, in particular, the following colorings are lucky:

<image>

While these colorings are not lucky:

<image>
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const long long mod = 998244353;
const int maxn = 1e6 + 10;
const int inf = 0x3f3f3f3f;
long long qPow(long long base, long long n) {
  long long res = 1;
  while (n) {
    if ((n & 1)) res = (res * base) % mod;
    base = (base * base) % mod;
    n >>= 1;
  }
  return res;
}
long long n;
int main() {
  while (~scanf("%lld", &n)) {
    long long ans = (qPow(3, n * n) - qPow((qPow(3, n) - 3), n) + mod) % mod;
    int f = -1;
    long long t = 0, c1 = 1;
    for (int i = 1; i <= n; i++) {
      f *= -1;
      c1 = (c1 * (n - (i - 1))) % mod;
      c1 = (c1 * qPow(i, mod - 2)) % mod;
      ans += (f * c1 % mod *
              (3 * qPow(qPow(3, n - i) - 1, n) % mod +
               (qPow(3, i) - 3) % mod * qPow(3, (n - i) % mod * n) % mod) %
              mod) %
             mod;
    }
    ans = (ans % mod + mod) % mod;
    printf("%lld\n", ans);
  }
  return 0;
}
