(defconstant +mod998+ 998244353) (defconstant +mod107+ 1000000007) (defun mod-exp (a n m) (let ((result 1) (base (mod a m))) (loop while (> n 0) do (when (oddp n) (setf result (mod (* result base) m))) (setf base (mod (* base base) m)) (setf n (floor n 2))) result)) (defun main (&rest argv) (declare (ignorable argv)) (let* ((h (read)) (w (read)) (m (read)) (a 1) (b 1)) (loop for i below (1- (+ h w)) do (setq a (* a (- m i))) (setq b (* b (1+ i)))) (loop for i below (1- h) do (setq a (* a (- (+ h w) i 2))) (setq b (* b (1+ i)))) (princ (mod (* (floor a b) (mod-exp m (* (1- h) (1- w)) +mod998+)) +mod998+)) (terpri))) (main)