/+ dub.sdl: name "A" dependency "dcomp" version="0.0.1" +/ import std.stdio, std.conv; import std.algorithm, std.range, std.random; import std.string, std.array, std.container, std.bigint; import core.bitop; // import dcomp.scanner; // import dcomp.numeric; Scanner sc; static this() { sc = new Scanner(); } const int MN = 2000100; const int MD = 1<<20; alias Mint = ModInt!(MD); int[] p2c; Mint[] fact, iFac; static this() { p2c = new int[MN]; fact = new Mint[MN]; iFac = new Mint[MN]; p2c[0] = 0; fact[0] = Mint(1); foreach (i; 1..MN) { p2c[i] = p2c[i-1]+i.bsf; fact[i] = fact[i-1]*Mint(i>>i.bsf); } iFac[MN-1] = Mint(1)/fact[MN-1]; foreach_reverse (i; 0..MN-1) { iFac[i] = iFac[i+1]*Mint((i+1)>>(i+1).bsf); } } int main() { int T; sc.read(T); foreach (_; 0..T) { int A, B, C; sc.read(A, B, C); int check() { if (C % 2 == 0) { return 0; } int X = B+C-1; int Y = B; int two = p2c[X]-p2c[Y]-p2c[X-Y]; Mint up = fact[X]*iFac[Y]*iFac[X-Y]*Mint(C)*Mint(1<