JerryL/AlgoSimBench huggingface dataset:
1205_F. Beauty of a Permutation

Define the beauty of a permutation of numbers from 1 to n (p_1, p_2, ..., p_n) as number of pairs (L, R) such that 1 ≤ L ≤ R ≤ n and numbers p_L, p_{L+1}, ..., p_R are consecutive R-L+1 numbers in some order. For example, the beauty of the permutation (1, 2, 5, 3, 4) equals 9, and segments, corresponding to pairs, are [1], [2], [5], [4], [3], [1, 2], [3, 4], [5, 3, 4], [1, 2, 5, 3, 4].

Answer q independent queries. In each query, you will be given integers n and k. Determine if there exists a permutation of numbers from 1 to n with beauty equal to k, and if there exists, output one of them.

Input

The first line contains a single integer q (1≤ q ≤ 10 000) — the number of queries.

Follow q lines. Each line contains two integers n, k (1 ≤ n ≤ 100, 1 ≤ k ≤ (n(n+1))/(2)) — the length of permutation and needed beauty respectively.

Output

For a query output "NO", if such a permutation doesn't exist. Otherwise, output "YES", and in the next line output n numbers — elements of permutation in the right order.

Examples

Input


4
1 1
5 6
5 8
5 10


Output


YES
1 
YES
2 4 1 5 3 
NO
YES
2 3 1 4 5 


Input


2
4 10
100 1


Output


YES
1 2 3 4 
NO

Note

Let's look at the first example.

The first query: in (1) there is only one segment consisting of consecutive numbers — the entire permutation.

The second query: in (2, 4, 1, 5, 3) there are 6 such segments: [2], [4], [1], [5], [3], [2, 4, 1, 5, 3].

There is no such permutation for the second query.

The fourth query: in (2, 3, 1, 4, 5) there are 10 such segments: [2], [3], [1], [4], [5], [2, 3], [2, 3, 1], [2, 3, 1, 4], [4, 5], [2, 3, 1, 4, 5].

Example input:
4
1 1
5 6
5 8
5 10

2
4 10
100 1


Example output:
YES
1
YES
2 4 1 5 3
NO
YES
4 1 2 3 5

YES
1 2 3 4 
NO


Tags: constructive algorithms
math
Difficulty rating: 3400

Solution:
#include <bits/stdc++.h>
using namespace std;
vector<int> f[110][110 * 110], bz[110];
int main() {
  for (int i = 4; i < 110; i++) {
    for (int j = 1; j <= i; j++)
      if (j % 2 == 0) bz[i].push_back(j);
    for (int j = 1; j <= i; j++)
      if (j & 1) bz[i].push_back(j);
    if (i & 1) swap(*--bz[i].end(), *--(--bz[i].end()));
  }
  f[1][1] = {1};
  f[2][3] = {1, 2};
  for (int i = 1; i < 110; i++)
    for (int j = 0; j <= i * (i + 1) / 2; j++)
      if (f[i][j].size()) {
        for (int k = 2; k + i - 1 < 110; k++) {
          auto &v = f[i + k - 1][j + k * (k + 1) / 2 - 1];
          if (!v.size()) {
            v = f[i][j];
            if (v.back() == v.size()) reverse(v.begin(), v.end());
            while (v.size() < i + k - 1) v.push_back(v.size() + 1);
          }
        }
        for (int k = 4; k + i - 1 < 110; k++) {
          auto &v = f[i + k - 1][j + k];
          if (!v.size()) {
            for (auto x : bz[k]) {
              if (x == 1) {
                for (auto x : f[i][j]) v.push_back(x);
              } else
                v.push_back(i + x - 1);
            }
          }
        }
      }
  int q, n, k;
  cin >> q;
  while (q--) {
    cin >> n >> k;
    if (!f[n][k].size())
      puts("NO");
    else {
      puts("YES");
      for (auto x : f[n][k]) cout << x << ' ';
      cout << '\n';
    }
  }
}
1213_G. Path Queries

You are given a weighted tree consisting of n vertices. Recall that a tree is a connected graph without cycles. Vertices u_i and v_i are connected by an edge with weight w_i.

You are given m queries. The i-th query is given as an integer q_i. In this query you need to calculate the number of pairs of vertices (u, v) (u < v) such that the maximum weight of an edge on a simple path between u and v doesn't exceed q_i.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the number of vertices in the tree and the number of queries.

Each of the next n - 1 lines describes an edge of the tree. Edge i is denoted by three integers u_i, v_i and w_i — the labels of vertices it connects (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) and the weight of the edge (1 ≤ w_i ≤ 2 ⋅ 10^5). It is guaranteed that the given edges form a tree.

The last line of the input contains m integers q_1, q_2, ..., q_m (1 ≤ q_i ≤ 2 ⋅ 10^5), where q_i is the maximum weight of an edge in the i-th query.

Output

Print m integers — the answers to the queries. The i-th value should be equal to the number of pairs of vertices (u, v) (u < v) such that the maximum weight of an edge on a simple path between u and v doesn't exceed q_i.

Queries are numbered from 1 to m in the order of the input.

Examples

Input


7 5
1 2 1
3 2 3
2 4 1
4 5 2
5 7 4
3 6 2
5 2 3 4 1


Output


21 7 15 21 3 


Input


1 2
1 2


Output


0 0 


Input


3 3
1 2 1
2 3 2
1 3 2


Output


1 3 3 

Note

The picture shows the tree from the first example: <image>

Example input:
3 3
1 2 1
2 3 2
1 3 2

7 5
1 2 1
3 2 3
2 4 1
4 5 2
5 7 4
3 6 2
5 2 3 4 1

1 2
1 2


Example output:
1 3 3

21 7 15 21 3

0 0


Tags: divide and conquer
dsu
graphs
sortings
trees
Difficulty rating: 1800

Solution:
from sys import setrecursionlimit as SRL, stdin

SRL(10 ** 7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())

fa = [i for i in range(200005)]
s = [1] * 200005


def find(x):
    t = []
    while fa[x] != x:
        t.append(x)
        x = fa[x]
    for i in t:
        fa[i] = x
    return fa[x]


ans = [0] * 200005
n, q = rrd()

w = []
for i in range(n - 1):
    x, y, z = rrd()
    w.append([z, x, y])

w.sort(key=lambda x: x[0])
for x in w:
    u = find(x[1])
    v = find(x[2])

    ans[x[0]] += s[u] * s[v]
    fa[u] = v
    s[v] += s[u]

for i in range(1, 200001):
    ans[i] += ans[i - 1]

q = list(rrd())

for x in q:
    print(ans[x], end=' ')
1218_E. Product Tuples

While roaming the mystic areas of Stonefalls, in order to drop legendary loot, an adventurer was given a quest as follows. He was given an array A = {a_1,a_2,...,a_N } of length N, and a number K.

Define array B as B(q, A) =  { q-a_1, q-a_2, ..., q-a_N }. Define function F as F(B,K) being sum of products of all K-tuples of elements in array B. For example, if the array B is [2,3,4,5], and with K=3, sum of products of all 3-tuples is $$$F(B, 3) = 2*3*4+2*3*5+3*4*5+2*4*5$$$

He was then given a number Q, number of queries of two types: 

  * Type 1: Given q, i, and d calculate F(B(q, A), K) where we make change to initial array as A[i] = d. 
  * Type 2: Given q, L, R, and d calculate F(B(q, A), K) where we make change to initial array as A[i] = A[i] + d for all i in range [L, R] inclusive. 



All changes are temporarily made to initial array, and don't propagate to following queries. Help the adventurer calculate the answer to a quest, and finally get that loot!

Input

In the first two lines, numbers N (1 ≤ N ≤ 2*10^4) and K (1 ≤ K ≤ N), the length of initial array A, and tuple size, followed by a_1,a_2,a_3,…,a_N (0 ≤ a_i ≤ 10^9) , elements of array A, in the next line. Then follows number Q (Q ≤ 10), number of queries. In the next Q lines come queries of the form: 

  * 1 q i d, for type 1, 
  * 2 q L R d, for type 2, 



as explained above (0 ≤ q, d ≤ 10^9, 1 ≤ i,L,R ≤ N)

Output

Print Q lines, the answers to queries, modulo 998244353.

Example

Input


5
2
1 2 3 4 5
3
1 6 1 1
1 6 5 2
2 6 2 3 1


Output


85
127
63

Note

In the first query array A = [1, 2, 3, 4, 5], B = [5, 4, 3, 2, 1], sum of products of 2-tuples = 85.

In second query array A = [1, 2, 3, 4, 2], B = [5, 4, 3, 2, 4], sum of products of 2-tuples = 127

In third query array A = [1, 3, 4, 4, 5], B = [5, 3, 2, 2, 1], sum of products of 2-tuples = 63

Example input:
5
2
1 2 3 4 5
3
1 6 1 1
1 6 5 2
2 6 2 3 1


Example output:
85
127
63


Tags: divide and conquer
fft
Difficulty rating: 2500

Solution:
#include <bits/stdc++.h>
using namespace std;
const int max_n = 20222, mod = 998244353;
int n, k, q, A[max_n], a[max_n];
int dp[max_n];
int solve() {
  int q1 = 0, q2 = 1;
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = min(i + 1, k); j >= max(1, k - (n - i - 1)); --j) {
      dp[j] = (dp[j] + 1LL * dp[j - 1] * a[i]) % mod;
    }
  }
  return dp[k];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  while (q--) {
    copy(A, A + n, a);
    int tp, x;
    scanf("%d%d", &tp, &x);
    if (tp == 1) {
      int pos, d;
      scanf("%d%d", &pos, &d);
      --pos;
      a[pos] = d;
    } else {
      int l, r, d;
      scanf("%d%d%d", &l, &r, &d);
      --l;
      for (int i = l; i < r; ++i) {
        a[i] += d;
      }
    }
    for (int i = 0; i < n; ++i) {
      a[i] = ((x - a[i]) % mod + mod) % mod;
    }
    printf("%d\n", solve());
  }
  return 0;
}
1240_F. Football

There are n football teams in the world. 

The Main Football Organization (MFO) wants to host at most m games. MFO wants the i-th game to be played between the teams a_i and b_i in one of the k stadiums. 

Let s_{ij} be the numbers of games the i-th team played in the j-th stadium. MFO does not want a team to have much more games in one stadium than in the others. Therefore, for each team i, the absolute difference between the maximum and minimum among s_{i1}, s_{i2}, …, s_{ik} should not exceed 2.

Each team has w_i — the amount of money MFO will earn for each game of the i-th team. If the i-th team plays l games, MFO will earn w_i ⋅ l.

MFO needs to find what games in what stadiums they need to host in order to earn as much money as possible, not violating the rule they set.

However, this problem is too complicated for MFO. Therefore, they are asking you to help them.

Input

The first line contains three integers n, m, k (3 ≤ n ≤ 100, 0 ≤ m ≤ 1 000, 1 ≤ k ≤ 1 000) — the number of teams, the number of games, and the number of stadiums.

The second line contains n integers w_1, w_2, …, w_n (1 ≤ w_i ≤ 1 000) — the amount of money MFO will earn for each game of the i-th game.

Each of the following m lines contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i) — the teams that can play the i-th game. It is guaranteed that each pair of teams can play at most one game.

Output

For each game in the same order, print t_i (1 ≤ t_i ≤ k) — the number of the stadium, in which a_i and b_i will play the game. If the i-th game should not be played, t_i should be equal to 0.

If there are multiple answers, print any.

Example

Input


7 11 3
4 7 8 10 10 9 3
6 2
6 1
7 6
4 3
4 6
3 1
5 3
7 5
7 3
4 2
1 4


Output


3
2
1
1
3
1
2
1
2
3
2

Note

One of possible solutions to the example is shown below:

<image>

Example input:
7 11 3
4 7 8 10 10 9 3
6 2
6 1
7 6
4 3
4 6
3 1
5 3
7 5
7 3
4 2
1 4


Example output:
1
2
1
1
2
1
2
2
3
3
1


Tags: graphs
Difficulty rating: 3100

Solution:
#include <bits/stdc++.h>
const int N = 1005;
int to[N << 1][N], id[N], n, m, k, c[N], x, y, col[N], eid[N << 1][N], cnt;
void dfs(int x, int cx, int cy) {
  if (to[x][cx]) dfs(to[x][cx], cy, cx);
  std::swap(to[x][cx], to[x][cy]);
  std::swap(eid[x][cx], eid[x][cy]);
  col[eid[x][cy]] = cy;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &x);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    y += n;
    if (!c[x]) id[x] = ++cnt;
    if (!c[y]) id[y] = ++cnt;
    c[x]++, c[y]++, c[x] %= k, c[y] %= k;
    x = id[x], y = id[y];
    int cx = 0, cy = 0;
    for (int j = 1; j <= k; j++) {
      if (!to[x][j]) cx = j;
      if (!to[y][j]) cy = j;
    }
    if (cx != cy) dfs(y, cx, cy);
    to[x][cx] = y, to[y][cx] = x;
    eid[x][cx] = i, eid[y][cx] = i;
    col[i] = cx;
  }
  for (int i = 1; i <= m; i++) printf("%d\n", col[i]);
}
1257_F. Make Them Similar

Let's call two numbers similar if their binary representations contain the same number of digits equal to 1. For example:

  * 2 and 4 are similar (binary representations are 10 and 100); 
  * 1337 and 4213 are similar (binary representations are 10100111001 and 1000001110101); 
  * 3 and 2 are not similar (binary representations are 11 and 10); 
  * 42 and 13 are similar (binary representations are 101010 and 1101). 



You are given an array of n integers a_1, a_2, ..., a_n. You may choose a non-negative integer x, and then get another array of n integers b_1, b_2, ..., b_n, where b_i = a_i ⊕ x (⊕ denotes bitwise XOR).

Is it possible to obtain an array b where all numbers are similar to each other?

Input

The first line contains one integer n (2 ≤ n ≤ 100).

The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 2^{30} - 1).

Output

If it is impossible to choose x so that all elements in the resulting array are similar to each other, print one integer -1.

Otherwise, print any non-negative integer not exceeding 2^{30} - 1 that can be used as x so that all elements in the resulting array are similar.

Examples

Input


2
7 2


Output


1


Input


4
3 17 6 0


Output


5


Input


3
1 2 3


Output


-1


Input


3
43 12 12


Output


1073709057

Example input:
4
3 17 6 0

3
1 2 3

2
7 2

3
43 12 12


Example output:
5

-1
1

1


Tags: bitmasks
brute force
hashing
meet-in-the-middle
Difficulty rating: 2400

Solution:
H = 15
MASK = (1 << H) - 1

n = int(input())
a = list(map(int, input().split()))

rec = {}
for x in range(1 << H):
    r = [bin(ai & MASK ^ x).count('1') for ai in a]
    d = tuple(r[-1] - ri for ri in r[:-1])
    rec.setdefault(d, x)

ans = None
for x in range(1 << H):
    r = [bin(ai >> H ^ x).count('1') for ai in a]
    y = rec.get(tuple(ri - r[-1] for ri in r[:-1]), None)
    if y is not None:
        ans = x << H | y
        break

print(-1 if ans is None else ans)
125_E. MST Company

The MST (Meaningless State Team) company won another tender for an important state reform in Berland.

There are n cities in Berland, some pairs of the cities are connected by roads. Each road has its price. One can move along any road in any direction. The MST team should carry out the repair works on some set of roads such that one can get from any city to any other one moving only along the repaired roads. Moreover, this set should contain exactly k capital roads (that is, the roads that start or finish in the capital). The number of the capital is 1.

As the budget has already been approved, the MST Company will profit by finding the set with minimum lengths of roads.

Input

The first input line contains three integers n, m, k (1 ≤ n ≤ 5000;0 ≤ m ≤ 105;0 ≤ k < 5000), where n is the number of cities in the country, m is the number of roads in the country, k is the number of capital roads in the required set. Then m lines enumerate the roads in question. Each road is specified by three numbers ai, bi, wi (1 ≤ ai, bi ≤ n; 1 ≤ w ≤ 105), where ai, bi are the numbers of cities linked by a road and wi is its length. 

Between each pair of cities no more than one road exists. There are no roads that start and finish in one city. The capital's number is 1.

Output

In the first line print the number of roads in the required set. The second line should contain the numbers of roads included in the sought set. If the sought set does not exist, print -1.

Examples

Input

4 5 2
1 2 1
2 3 1
3 4 1
1 3 3
1 4 2


Output

3
1 5 2 

Example input:
4 5 2
1 2 1
2 3 1
3 4 1
1 3 3
1 4 2


Example output:
3
1 5 2 


Tags: binary search
graphs
Difficulty rating: 2400

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 2, M = 1e5 + 5;
int n, m, k, par[N];
vector<int> vec;
struct edge {
  int u, v, i;
  long double w;
} e[M];
int getPar(int u) { return ~par[u] ? par[u] = getPar(par[u]) : u; }
bool check(double x) {
  for (int i = 0; i < m; i++) e[i].w += (!e[i].u || !e[i].v) * x;
  memset(par, -1, sizeof par);
  sort(e, e + m,
       [](edge x, edge y) { return x.w != y.w ? x.w < y.w : x.i < y.i; });
  int cnt = 0;
  for (int i = 0, x, y; i < m; i++)
    if ((x = getPar(e[i].u)) ^ (y = getPar(e[i].v))) {
      par[x] = y;
      vec.push_back(e[i].i);
      cnt += (!e[i].u || !e[i].v);
    }
  for (int i = 0; i < m; i++) e[i].w -= (!e[i].u || !e[i].v) * x;
  if (cnt == k) {
    cout << n - 1 << endl;
    for (int x : vec) cout << x + 1 << ' ';
    exit(0);
  }
  vec.clear();
  return cnt < k;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    cin >> e[i].u >> e[i].v >> e[i].w;
    e[i].u--, e[i].v--, e[i].i = i;
  }
  for (double l = -1e9, r = 1e9, i = 0; i < 100; i++) {
    double mid = (l + r) / 2;
    (check(mid) ? r : l) = mid;
  }
  cout << -1 << endl;
}
1268_D. Invertation in Tournament

You are given a tournament — complete directed graph.

In one operation you can pick any vertex v and change the direction of all edges with v on one of the ends (i.e all edges u → v change their orientation to v → u and vice versa).

You want to make the tournament strongly connected with the smallest possible number of such operations if it is possible. 

Also, if it is possible, you need to find the number of ways to make this number of operations to make graph strongly connected (two ways are different if for some i vertex that we chose on i-th operation in one way is different from vertex that we chose on i-th operation in another way). You only need to find this value modulo 998 244 353.

Input

The first line of input contains one integer n (3 ≤ n ≤ 2000): the number of vertices in the tournament.

Following n lines contain a description of the given tournament, each of them contains a binary string of length n. If j-th character of i-th string is equal to '1', then the graph has an edge i → j.

It is guaranteed that there are no edges i → i and the graph has exactly one edge among i → j and j → i for different i and j.

Output

If it is not possible to convert tournament to strongly connected with the given operations, output "-1".

Otherwise, output two integers: the smallest number of operations that you need to make the given graph strongly connected and the number of ways to do this number of operations to make graph strongly connected, modulo 998 244 353.

Examples

Input


3
010
001
100


Output


0 1


Input


4
0010
1000
0100
1110


Output


-1


Input


6
010000
001000
100000
111001
111100
111010


Output


2 18

Example input:
4
0010
1000
0100
1110

6
010000
001000
100000
111001
111100
111010

3
010
001
100


Example output:
-1
2 18
0 1

Tags: brute force
divide and conquer
graphs
math
Difficulty rating: 3200

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int n, deg[N], a[N];
bool ed[N][N];
void change(int u) {
  for (int v = 0; v < n; v++) {
    deg[u] -= ed[u][v], deg[u] += ed[u][v] ^= true;
    deg[v] -= ed[v][u], deg[v] += ed[v][u] ^= true;
  }
}
bool check() {
  copy(deg, deg + n, a);
  sort(a, a + n, greater<int>());
  for (int i = 1, sum = a[0]; i < n; sum += a[i++])
    if (sum == i * (i - 1) / 2 + i * (n - i)) return false;
  return true;
}
int main() {
  cin >> n;
  for (int u = 0; u < n; u++)
    for (int v = 0; v < n; v++) {
      char c;
      cin >> c;
      deg[u] += ed[u][v] = c - '0';
    }
  if (check()) return cout << "0 1", 0;
  int ted = 0;
  for (int u = 0; u < n; change(u++)) change(u), ted += check();
  if (ted) return cout << "1 " << ted, 0;
  if (n == 6) return cout << "2 18", 0;
  cout << -1;
}
1270_C. Make Good

Let's call an array a_1, a_2, ..., a_m of nonnegative integer numbers good if a_1 + a_2 + ... + a_m = 2⋅(a_1 ⊕ a_2 ⊕ ... ⊕ a_m), where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).

For example, array [1, 2, 3, 6] is good, as 1 + 2 + 3 + 6 = 12 = 2⋅ 6 = 2⋅ (1⊕ 2 ⊕ 3 ⊕ 6). At the same time, array [1, 2, 1, 3] isn't good, as 1 + 2 + 1 + 3 = 7 ≠ 2⋅ 1 = 2⋅(1⊕ 2 ⊕ 1 ⊕ 3).

You are given an array of length n: a_1, a_2, ..., a_n. Append at most 3 elements to it to make it good. Appended elements don't have to be different. It can be shown that the solution always exists under the given constraints. If there are different solutions, you are allowed to output any of them. Note that you don't have to minimize the number of added elements!. So, if an array is good already you are allowed to not append elements.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10 000). The description of the test cases follows.

The first line of each test case contains a single integer n (1≤ n ≤ 10^5) — the size of the array.

The second line of each test case contains n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 10^9) — the elements of the array.

It is guaranteed that the sum of n over all test cases does not exceed 10^5.

Output

For each test case, output two lines.

In the first line, output a single integer s (0≤ s≤ 3) — the number of elements you want to append.

In the second line, output s integers b_1, ..., b_s (0≤ b_i ≤ 10^{18}) — the elements you want to append to the array.

If there are different solutions, you are allowed to output any of them.

Example

Input


3
4
1 2 3 6
1
8
2
1 1


Output


0

2
4 4
3
2 6 2

Note

In the first test case of the example, the sum of all numbers is 12, and their ⊕ is 6, so the condition is already satisfied.

In the second test case of the example, after adding 4, 4, the array becomes [8, 4, 4]. The sum of numbers in it is 16, ⊕ of numbers in it is 8.

Example input:
3
4
1 2 3 6
1
8
2
1 1


Example output:
2
6 18 
2
8 16 
2
0 2 


Tags: bitmasks
constructive algorithms
math
Difficulty rating: 1400

Solution:
for _ in " "*int(input()):
    a=int(input());b=list(map(int,input().split()));s=0
    for i in b:s^=i
    print(2,"\n",s,s+sum(b))
1278_F. Cards

Consider the following experiment. You have a deck of m cards, and exactly one card is a joker. n times, you do the following: shuffle the deck, take the top card of the deck, look at it and return it into the deck.

Let x be the number of times you have taken the joker out of the deck during this experiment. Assuming that every time you shuffle the deck, all m! possible permutations of cards are equiprobable, what is the expected value of x^k? Print the answer modulo 998244353.

Input

The only line contains three integers n, m and k (1 ≤ n, m < 998244353, 1 ≤ k ≤ 5000).

Output

Print one integer — the expected value of x^k, taken modulo 998244353 (the answer can always be represented as an irreducible fraction a/b, where b mod 998244353 ≠ 0; you have to print a ⋅ b^{-1} mod 998244353).

Examples

Input


1 1 1


Output


1


Input


1 1 5000


Output


1


Input


2 2 2


Output


499122178


Input


998244352 1337 5000


Output


326459680

Example input:
998244352 1337 5000

1 1 1

1 1 5000

2 2 2


Example output:
326459680

1

1

499122178


Tags: combinatorics
dp
math
number theory
probabilities
Difficulty rating: 2600

Solution:
dp=[0]*5010
dp[0]=1
n,m,k=map(int,input().split())
t=998244353
for i in range(k):
    for j in range(len(dp)-1, -1, -1):
        if j==0:dp[j]=0
        else:dp[j]=(dp[j-1]*(n-j+1)+dp[j]*j)%t
c=0
for i in range(k+1):
    c+=pow(m,max(n-i,0),t)*dp[i]
    c%=t
den=pow(m,n,t)
den=pow(den,t-2,t)
print((den*c)%t)