more N Mod M

Haskell, Python2