HW5, Implemented Dlog, but for does not work without ord implementation.