this subtask problem F the difference second subtask constraint value m time limit you need solve subtask order hack onethere n1 distinct colour universe number 0 n there strip paper m centimetre long initially paint colour 0 Alice take brush paint strip following process for 1 n order pick integer 0 leq a_i b_i leq m segment a_i b_i currently paint single colour repaint colour Alice choose segment way centimetre paint colour 0 Formally segment i1 paint colour c_i c_i neq 0 every colour 0 visible stripcount number different pair sequence a_i_i1n b_i_i1n result configuration since number large output modulo 998244353