Scanf.scanf "%d %d %d %d" (fun a b c d ->
    let mat = Array.make_matrix (c + 1) (d + 1) (-1) in
    mat.(a).(b) <- 1;
    let z = 998244353 in
    let ( +@) a b = (a + b) mod z in
    let ( -@) a b = ((a - b) mod z + z) mod z in
    let ( *@) a b = (a * b) mod z in
    let rec calc w h =
        if mat.(w).(h) >= 0 then mat.(w).(h) else (
            let r = 
                if w = a then calc w (h - 1) *@ w else
                if h = b then calc (w - 1) h *@ h else
                    calc w (h - 1) *@ w +@ calc (w - 1) h *@ h -@ calc (w - 1) (h - 1) *@ (w - 1) *@ (h - 1)
            in
            mat.(w).(h) <- r;
            r
        )
    in
    calc c d |> Printf.printf "%d\n"
)