Hi,
Barry Cipra has rephrased my question in far superior clarity and brevity in an addendum to his answer below. I quote:
"If you number the squares of an $m×n$ grid, you can let three groups act on the numbering: arbitrary permutations of the rows, arbitrary permutations of the columns, and cyclic permutations of the numbers. [...]. What the OP wants,[...], is the number of orbits among the $(mn)!$ numberings of the grid under the combined action of all three groups."
For recreation you can read my original convoluted way of asking a mathematically equivalent question. I leave it for historical reasons until somebody with lots of rep removes it or tells me to do so:
Please excuse the clumsy style, I am no mathematician.
Definition 1: Given a sequence $U=\{1,...,N\}$ of length N, extend it periodically to minus and plus infinity and call this $U_{\infty}$ (e.g. if $N=2$ then $U_{\infty}=\{...,2,1,2,1,2,1,2,...\}$).
Now I want to make sequences of pairs out of this. Basically getting two sequences as result.
Definition 2: Given $N,n$ and $m$ with $N,n,m \in \mathbb{N}$, and $n m =N$, call $f$ a splitting of $N$ into $n$ and $m$ if $f$ is a bijective function $f:\{1,...,N\} \rightarrow A\times B$, where $A$ and $B$ are the sets $A=\{1,...,n\}$ and $B=\{1,..,m\}$.
Definition 3: Each splitting $f$ defines an infinite sequence of pairs, denoted $f_{\infty}$, by taking the sequence $$\{f(1),...,f(N)\}={a_1 \choose b_1},...,{a_N \choose b_N}$$ where $a_i \in A, b_i \in B$ and then extending this periodically to plus and minus infinity.
Definition 4: Now define two splittings $f$ and $g$ equivalent if any of the two conditions hold:
they produce the same infinite sequence $f_{\infty} = g_{\infty}$ (this gets rid of cyclic permutations like ($(a_n,b_n) \rightarrow (a_{n+1 \;\text{mod}\;N},b_{n+1 \;\text{mod}\;N})$).
if $f_{\infty}$ can be obtained from $g_{\infty}$ by renaming the elements in $A$ or $B$ or both.1.
For example, take $N=6$, $A= \{1,2\}, B=\{1,2,3\}$, and define $f$ such that $f_{\infty}$ is as follows (I will only write one period): $$...{1 \choose 1},{1 \choose 2},{1 \choose 3},{2 \choose 1},{2 \choose 2},{2 \choose 3}...$$
This would be equivalent to $$...{2 \choose 2},{1 \choose 3},{1 \choose 1},{1 \choose 2},{2 \choose 3},{2 \choose 1}...$$ because the latter can be obtained from the former by renaming the elements of set $B$ like $\{1\rightarrow 3,2\rightarrow 1,3\rightarrow 2\}$ and then putting the last pair first.
Now I would like to know, how many non-equivalent splittings are there?
Examples:
As suggested by comments below, here two simple examples to make it more clear and maybe help intuition:
$n=1$ such that $N=m$:
There is only one distinctive splitting, as every $g_{\infty}$ can be obtained from an arbitrary $f_{\infty}$ by renaming the elements in $B$.
$N=4,n=2$ such that $m=2$ as well:
The $N$ elements in $A \times B$ can be put into a sequence in $N!$ ways, or in other words there are $N!$ splittings. So here there are $24$ already! If we use the method suggested by Barry Cipra in his answer below to sort out those splittings that are equivalent by the renaming of elements within $A$ or $B$, then we are left with $6$ sequences. The $2 \times 2$ grids for these 6 (the requirement is the 1 in top left corner, and increasing numbers in top row and leftmost column) are:
1 2 | 1 2 | 1 3 | 1 3 | 1 4 | 1 4
3 4 | 4 3 | 2 4 | 4 2 | 2 3 | 3 2
the sequences corresponding to these are (cartesian coordinate style, the number in the grid element corresponds to the slot in the sequence):
$${1 \choose 2},{2 \choose 2},{1 \choose 1},{2 \choose 1}$$ $${1 \choose 2},{2 \choose 2},{2 \choose 1},{1 \choose 1}$$ $${1 \choose 2},{1 \choose 1},{2 \choose 2},{2 \choose 1}$$ $${1 \choose 2},{2 \choose 1},{2 \choose 2},{1 \choose 1}$$ $${1 \choose 2},{1 \choose 1},{2 \choose 1},{2 \choose 2}$$ $${1 \choose 2},{2 \choose 1},{1 \choose 1},{2 \choose 2}$$
But of those the first and the last, the second and the fifth and the third and the first are equivalent due to cyclic permutation and the right renaming within $A$ or $B$. Note that only a cyclic permutation itself is not enough. Also, it just happens that those equivalent here are the "time-reversals" of each other...
So we end up with three non-equivalent splittings in this case.