```cpp
invT[1] = 1;
for (int i = 2; i < N; i++)
  invT[i] = (mod - mod / i) * invT[mod % i] % mod;
```

$$
p=ax+b \\
ax+b \equiv 0 \pmod p\\
ab^{-1}+x^{-1} \equiv 0 \pmod p \\
x^{-1} \equiv -ab^{-1} \pmod p \\
x^{-1} \equiv -\left \lfloor \frac{p}{x} \right \rfloor (p\bmod x)^{-1} \pmod p \\
x^{-1} \equiv (p-p/x) (p\bmod x)^{-1} \pmod p \\
$$

