private static State<IDictionary<BigInteger, BigInteger>, BigInteger> FibM(BigInteger z)
 {
     return z <= 1
         ? z.Insert<IDictionary<BigInteger, BigInteger>, BigInteger>()
         : from u in State.Get<IDictionary<BigInteger, BigInteger>, IMaybe<BigInteger>>(d => d.Get(z))
             from v in u.Select(n => n.Insert<IDictionary<BigInteger, BigInteger>, BigInteger>()).GetOrElse(() =>
                 from r in FibM(z - 1)
                 from s in FibM(z - 2)
                 let t = r + s
                 from _ in State.Mod<IDictionary<BigInteger, BigInteger>>(d => d.Put(Tuple.Create(z, t)))
                 select t)
             select v;
 }