Implement the function count_valid_permutations which calculates the number of valid permutations for drawing a tree on a circle such that the edges do not cross each other. The result should be computed modulo 998244353.
Input Requirements
The function should accept the following parameters:
n (int): The number of nodes in the tree. It must be a positive integer.
edges (list of tuples): A list of tuples where each tuple contains two integers (u, v) representing the nodes connected by the edge. The integers must be in the range [1, n], and the list should contain exactly n-1 tuples since it's a tree structure.
Output Requirements
The function should return:
An integer representing the number of valid permutations modulo 998244353.
Implementation Details
Create a file named /app/solution.py.
Implement the count_valid_permutations function within this file, following the provided function signature and documentation.
Example
For example, if the inputs are:
python
n = 3
edges = [(1, 2), (2, 3)]
The expected output should be:
python
3
Ensure that your implementation adheres to the described requirements and handles edge cases, such as minimal and maximal valid inputs.