Codeforces Round 493 (Div. 1)
C
Sky Full of Stars
Codeforces
2500
原题
← BD →
翻译中…

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 \cdot 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 \le n \le 1000\,000$) — the number of rows and columns in the calendar.

翻译中…

Output

翻译中…

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

翻译中…

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

翻译中…

样例

Input #1
1
Output #1
3
InputCopy OutputCopy
Input #2
2
Output #2
63
InputCopy OutputCopy
Input #3
3
Output #3
9933
InputCopy OutputCopy
题目信息
题号
997C
时间限制
4 s
内存限制
256 MB
标签
组合数学
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。