#!ruby -na e=->n,m{t=1;(1..n).map{|i|t*=(i%m*t)%m};t} f=->n,m{n<2?1%m:1&n<0?(2**n%m)*f[n,m]*g[n-1,m]%m:n*f[n-1,m]%m} $F[1]&&p(f[*$F.map(&:to_i)])