eolymp
bolt
Try our new interface for solving problems
Problems

Peaceful Rooks

Peaceful Rooks

A rook is a chess piece that moves along ranks and files. Let us consider \textbf{k} white rooks and \textbf{l} black rooks on an \textbf{m}×\textbf{n} chessboard. We call the arrangement of the rooks on the chessboard \textit{peaceful} if no white rook attacks a black one (and vice-versa). Given \textbf{m}, \textbf{n}, \textbf{k} and \textbf{l}, find the number of peaceful arrangements of the rooks on the chessboard. \InputFile The input file contains four integer numbers: \textbf{m}, \textbf{n}, \textbf{k} and \textbf{l} (\textbf{2} ≤ \textbf{m}, \textbf{n} ≤ \textbf{10}, \textbf{1} ≤ \textbf{k}, \textbf{1} ≤ \textbf{l}, \textbf{k + l} ≤ \textbf{m·n}). \OutputFile Output one integer number - the number of peaceful arrangements of \textbf{k} white and \textbf{l} black rooks on the \textbf{m}×\textbf{n} chessboard.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 3 2 2
Output example #1
18