If calculating by hand, then m and n (levels of each sample) can have different values, at least according to textbook critical Values for the Mann–Whitney (Wilcoxon) Statistic.

The other thing that is really confusing me is how R calculates df for each of these tests. I mean, for e.g., if m = 10 and n = 10, then shouldn't df = m-1 +n-1 ? Yet if I run a Kruskal-wallis test it says df = 3