P16608 [SYSUCPC 2025] Larger or Smaller

Description

In his recent work on permutation properties, $\texttt{Dr.Z}$ investigates the relationship between element values and their indices. A key focus is the cardinality of the set of indices $i$ where $p_i>i$ (called $\bf{larger\ position}$) and where $p_i

Input Format

The only line contains two integers $n,m(2\le n\le 2000,2\le m\le 10^9+7)$.

Output Format

There are $n-1$ rows in total. The $i$-th row contains $n-i$ integers. The $j$-th integer represents the result of $f(n,i,j)$ modulo $m$.

Explanation/Hint

The five permutations of $x=1,y=3$ are $[1,5,2,3,4], [4,1,2,3,5], [5,1,2,4,3], [5,1,3,2,4]$, and $[5,2,1,3,4]$.