PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000240. Đếm dãy có ít nhất hai cách xóa hợp lệ (Counting Arrays)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm dãy có ít nhất hai cách xóa hợp lệ (Counting Arrays)

Đếm dãy có ít nhất hai cách xóa hợp lệ (Counting Arrays)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given n,mn,m, consider arrays of every length 1..n1..n with entries from 1..m1..m. An element at its current 1-indexed position ii can be removed if its GCD with ii is 1, and remaining elements shift left. Count arrays admitting at least two distinct complete removal-position sequences, modulo 998244353998244353.

Input

One line with n,mn,m.

Output

Print the number of ambiguous arrays modulo 998244353998244353.

Subtasks

  • Subtask 1 (20 points): 2≤n≤20, 1≤m≤202\le n\le20,\ 1\le m\le20.
  • Subtask 2 (30 points): 2≤n≤3000, 1≤m≤1062\le n\le3000,\ 1\le m\le10^6.
  • Subtask 3 (50 points): 2≤n≤3⋅105, 1≤m≤10122\le n\le3\cdot10^5,\ 1\le m\le10^{12}.

Examples

Example 1

Input

2 3

Output

6

Explanation

All 6 ambiguous arrays have length two, and length-one arrays never have two distinct deletion orders.

Example 2

Input

4 2

Output

26

Explanation

Among 2+4+8+16=302+4+8+16=30 arrays, exactly four have a unique deletion sequence.