Pak Chanek mirror shape circle there n lamp circumference number 1 n clockwise order the length arc lamp lamp i1 D_i 1 leq leq N1 meanwhile length arc lamp N lamp 1 d_npak Chanek want colour lamp M different colour each lamp colour M colour however different lamp colour lamp triangle consider lamp vertice right triangle triangle angle exactly 90 degreesthe follow example lamp colouring configuration circular mirror figure 1 example incorrect colouring lamp 1 2 3 form right trianglefigure 2 example correct colouringfigure 3 example correct colour before colour lamp Pak Chanek want know number distinct colouring configuration Count number distinct possible lamp colouring configuration modulo 998244353