Solution:
If m=1 or n=1 a hut placed at one end has only one adjacent hut, which therefore cannot be connected to any other hut (the p bridges departing from the first hut must necessarily reach the adjacent hut). Hence the only possibilities are (m,n)=(1,2) or (m,n)=(2,1) with p arbitrary.
If m and n are both greater than 1, one cannot have p=1, since from a hut only one other hut could be reached.
Let us now consider the case where m,n and p are all greater than 1. We show that it is possible to place the bridges if and only if m⋅n is even (and p can be any value). Coloring the huts white and black as on an ordinary chessboard, we have that every bridge has one white end and one black end. If m⋅n is odd, that is m and n are both odd, it is not possible to have the same number of bridges depart from every hut, since the number of white huts differs by one (more or less) from that of the black huts.
On the other hand, if (for instance) m is even, one can form 2×n blocks in the following way:

The four half-bridges a,b,c,d serve to connect the blocks to one another (obviously in the case of the outermost blocks two of them are welded together to form a single bridge).