You are given two sets of vertices such that the first set contains $$n$$ vertices labeled $$1$$ to $$n$$ and the second set contains $$m$$ vertices labeled $$1$$ to $$m$$.
Add edges between these vertices such that no two vertices from the same set are adjacent and each vertex is incident on at least one edge. Find out the number of graphs that can be formed under the above constraints.
CONSTRAINTS:
\(1 \leq n \leq m \leq 10^6\)
INPUT:
A single line containing two integers $$n$$ and $$m$$.
OUTPUT:
A single integer denoting the answer. Since the answer can be large, output it modulo \(998244353\) .
Denote a pair \((u,v)\) as an edge where u is a vertex from the first set and v from the second.
Then the edge sets for the 7 graphs are:
- \({(1, 1), (2, 2)}\)
- \({(1, 2), (2, 1)}\)
- \({(1, 1), (1, 2), (2, 2)}\)
- \({(1, 1), (1, 2), (2, 1)}\)
- \({(1, 1), (2, 1), (2, 2)}\)
- \({(1, 2), (2, 1), (2, 2)}\)
- \({(1, 1), (1, 2), (2, 1), (2, 2)}\)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor