Accessing list elements when counting the number of rectilinear paths
Code organization

The definitions of readInts and read2Ints disrupt the mathematical code.  The I/O routines belong further down, just before main.

import Data.Maybe and import qualified Data.ByteString.Char8 as C appear to be superfluous.

Abstraction

It is not immediately obvious from reading


solve x y = anstable!!(x+y)*(modExp (anstable!!x) ip p)*(modExp (anstable!!y) ip p)`rem`1000000007



that it is calculating

$$ \left(\begin{array}{c} x+y \\ y \end{array}\right) = \frac{(x + y)!}{x!\ y!}\mod p $$

I would expect to see

solve x y = modCombination (x + y) y p

modCombination n r p =
  (factorial n) * (modInvFactorial r) * (modFactorial (n - r)) `rem` p'
  where …


In some ways, you come close, but anstable obscures your intention.  Why not ansTable, with the customary capitalization so that it doesn't look like an stable? Why did you rename it from fact in the first place, making it more confusing?  Why is 1000000007 hard-coded at the end, when you could have used p?

What is ip?  1000000005 is a magic number that appears nowhere in the stated challenge.  What about 2000001?  Where did that limit come from?