Note: This is a more limited version of a challenge from 2014 that only received one answer. That challenge required participants write two programs; this challenge is essentially one half of that. The text here is original, but credit for the idea goes to Matthew Butterick, who is no longer active on the site.
Given a matrix of integers \$M\$, find the smallest (by number of elements) submatrix \$N\$ that contains at least one of every element present in \$M\$. (A submatrix is a “matrix formed by taking a block of the entries … from the original matrix.”)
$$ M = \begin{bmatrix}9 & 0 & -4 & 5 & 1 & -4\\ 3 & -2 & 5 & 9 & -7 & 1\\ \color{blue}{0} & \color{blue}{-7} & \color{blue}{-2} & \color{blue}{5} & 9 & 5\\ \color{blue}{9} & \color{blue}{9} & \color{blue}{5} & \color{blue}{-4} & 1 & 9\\ \color{blue}{-4} & \color{blue}{1} & \color{blue}{8} & \color{blue}{3} & -4 & -4\end{bmatrix} $$
In the above example the submatrix \$N\$, shown in blue, has at least one of every element in \$M\$, and there is no smaller submatrix with that property. Note that some elements (i.e. \$8\$) do not exist outside of \$N\$ and some elements in \$N\$ are duplicated (i.e. \$9\$).
Input
Input will consist of a matrix \$M\$ in any convenient format. It will be at least \$1\times 1\$.
Output
Output may be either of:
The submatrix \$N\$ in any convenient format. If it's returned as a 1-dimensional list its dimensions must also be given.
The position of \$N\$ within \$M\$, given either as the row and column positions of two of its corners diagonal from each other, or as the row and column position of one of its corners and its width and height. The answer should indicate which corners are given.
If multiple submatrices are tied for smallest representative submatrix, any one may be returned, or all may be returned.
Rules
Default I/O rules and standard rules apply. Standard loopholes are forbidden.
This is code-golf; shortest solution in bytes wins.
Test cases
The below test cases each show one possible correct output, but not all possible valid outputs.
Input
3 3 -9 0 3
3 3 1 -8 1
0 0 0 8 -8
3 8 8 0 3
0 8 8 0 -9
Output
-8 1
8 -8
0 3
0 -9
Input
3 6 -8 -1
-8 3 1 -2
-8 -2 -1 -2
Output
6 -8
3 1
-2 -1
Input
-8 -7 -4 7 -7
-7 -6 7 -7 -7
8 -3 -8 -6 -4
-4 5 -7 7 8
-8 7 8 -4 -3
Output
-3 -8 -6 -4
5 -7 7 8
Input
-8 7
-2 -4
Output
-8 7
-2 -4
[[6,-8,-1],[3,1,-2]]
(top-right 2x3 block). \$\endgroup\$