P16450 [XJTUPC 2026] But Nothing Will Change 3

Background

:::epigraph "You have seen how powerful this world is, right?" "I have seen how powerful I am!" :::

Description

After resolving the knot in the hearts of Xiao Yi and Xiao Huan, you went on to solve many, many permutation counting problems. These problems came in all kinds of forms: some combined pieces of information that seemed totally unrelated, some had complicated inequality relations that left you clueless, some were based on classic problems but had their nice properties ruined by an extra constraint that looked insignificant, and some looked simple in structure but had strict and seemingly unreachable complexity requirements. Among them were big-observation problems, big-case-analysis problems, dp problems, inclusion-exclusion problems, bijection problems, generating function problems, divide-and-conquer NTT problems, polynomial recurrence problems, Lagrange inversion problems, lattice path counting problems, Young tableau problems, group theory problems, and even "please enter text" problems that could not be classified because they involved too many elements. Although the memory is far away, you still remember the shock when you first encountered these problems. Sometimes, it feels even clearer than the feeling when you finally solved them. You helped Xiao S explain the distribution of permutations that make the number of bubble sort swaps attain its lower bound, helped Xiao K find a graduation trip plan that keeps everyone comfortable, brought back Ruyi's goal that was lost due to an accident, discovered endless stories hidden in rises, falls, and cycles, computed the possibilities hidden at the intersection of "routines" and "intelligence" on that note from years ago, answered Helder's confusion behind "heartbeat" and in front of "tide"…… As you solved more and more problems, your deeds spread through every street and alley. People admired your passion and ability, and came to you with permutation counting problems they could not solve. You became a well-known permutation counting master— —Anyway, those ups and downs and thrilling days are already over. Today is also an ordinary day. Let $f(n,m)$ ($3\le m\le n$) denote the number of sequences $P_1,P_2,\cdots,P_m$ that satisfy the following properties: - $P_1,P_2,\cdots,P_m$ are pairwise distinct and all belong to the set $\{1,2,\cdots,n\}$. - For any $i$ ($3\le i\le m$), it holds that $[P_i

Input Format

The input contains one line with a single integer $n$ ($3\le n\le 10^6$).

Output Format

The output contains one line with a single integer, which is the answer modulo $998244353$.

Explanation/Hint

Translated by ChatGPT 5