{"problem":{"name":"Range Argmax","description":{"content":"Given are an integer $N$ and $M$ pairs of integers. The $i$\\-th pair is $(L_i,R_i)$. Find the number of integer sequences $x=(x_1,x_2,\\cdots,x_M)$ that can be generated as follows, modulo $998244353$.","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc056_b"},"statements":[{"statement_type":"Markdown","content":"Given are an integer $N$ and $M$ pairs of integers. The $i$\\-th pair is $(L_i,R_i)$.\nFind the number of integer sequences $x=(x_1,x_2,\\cdots,x_M)$ that can be generated as follows, modulo $998244353$.\n\n*   Provide a permutation $p=(p_1,p_2,\\cdots,p_N)$ of $(1,2,\\cdots,N)$.\n*   For each $i$ ($1 \\leq i \\leq M$), let $x_i$ be the index of the largest element among $p_{L_i},p_{L_i+1},\\cdots,p_{R_i}$. That is, $\\max(p_{L_i},p_{L_i+1},\\cdots,p_{R_i})=p_{x_i}$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 300$\n*   $1 \\leq M \\leq N(N-1)/2$\n*   $1 \\leq L_i < R_i \\leq N$\n*   $(L_i,R_i) \\neq (L_j,R_j)$ ($i \\neq j$)\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$\n$L_1$ $R_1$\n$L_2$ $R_2$\n$\\vdots$\n$L_M$ $R_M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc056_b","tags":[],"sample_group":[["3 2\n1 2\n1 3","4\n\nFor example, for $p=(2,1,3)$, we will have $x=(1,3)$.\nThe four sequences that meet the requirement are $x=(1,1),(1,3),(2,2),(2,3)$."],["6 3\n1 2\n3 4\n5 6","8"],["10 10\n8 10\n5 8\n5 7\n2 5\n1 7\n4 5\n5 9\n2 8\n7 8\n3 9","1060"]],"created_at":"2026-03-03 11:01:14"}}