I would like to seek help on the complexity of the following problem. Given positive integers $m$, $n$, $D_1$ and $D_2$, find all sequences $a_1\lt a_2 \lt \dots \lt a_n$ are there such that:
- each $a_i\in\{1, \dots, m\}$
- $\sum_{i=1}^n a_i = D_1$
- $\sum_{i=1}^n a_i^2 = D_2$.
I want to know the complexity with respect to $m$, $n$, $D_1$ and $D_2$.
For example, when $m=12$, $n=4$, $D_1=26$ and $D_2=214$ the solutions are
$$ 3,5, 6, 12\qquad 2, 5, 8, 11\qquad 1, 7, 8, 10$$