For what positive integers $n$ and $k$ do there exits integers $a_1,a_2,\dots,a_n$ and $b_1,b_2,\dots,b_k$ such that the products $a_ib_j$ ($1\le i\le n,1\le j\le k$) give pairwise different residues modulo $nk$?
1. **Construction of \(a_i\) and \(b_j\):**
   We start by constructing the sequences \(a_i\) and \(b_j\) as follows:
   \[
   a_i = ki + 1 \quad \text{for} \quad 1 \le i \le n
   \]
   \[
   b_j = nj + 1 \quad \text{for} \quad 1 \le j \le k
   \]
   This gives us:
   \[
   a_1 = k + 1, \, a_2 = 2k + 1, \, \ldots, \, a_n = nk + 1
   \]
   \[
   b_1 = n + 1, \, b_2 = 2n + 1, \, \ldots, \, b_k = kn + 1
   \]

2. **Verification of pairwise different residues:**
   We need to show that the products \(a_i b_j\) give pairwise different residues modulo \(nk\). Consider:
   \[
   a_i b_j = (ki + 1)(nj + 1) = kinj + ki + nj + 1
   \]
   Modulo \(nk\), this simplifies to:
   \[
   a_i b_j \equiv ki + nj + 1 \pmod{nk}
   \]
   Since \(\gcd(k, n) = 1\), the set \(\{ki + nj : 1 \le i \le n, 1 \le j \le k\}\) forms a complete residue system modulo \(nk\). This ensures that \(a_i b_j\) are pairwise distinct modulo \(nk\).

3. **Necessity of \(\gcd(k, n) = 1\):**
   We now show that \(\gcd(k, n) = 1\) is necessary. 

   **Claim 1:** \(\gcd(a_i, nk) \le n\) for all \(i\) and \(\gcd(b_j, nk) \le k\) for all \(j\).

   *Proof:* Fix \(i\). We show \(\gcd(a_i, nk) \le n\). Observe that \(a_i b_1, a_i b_2, \ldots, a_i b_k\) are distinct modulo \(nk\). If \(d = \gcd(a_i, nk)\), then \(b_1, b_2, \ldots, b_k\) must be distinct modulo \(\frac{nk}{d}\). By the Pigeonhole Principle, \(\frac{nk}{d} \ge k \implies d \le n\).

   Similarly, for \(b_j\), \(\gcd(b_j, nk) \le k\).

   **Claim 2:** If some prime \(p \mid n\), then \(p \nmid b_1 b_2 \cdots b_k\). Similarly, if \(p \mid k\), then \(p \nmid a_1 a_2 \cdots a_n\).

   *Proof:* Suppose \(p \mid n\). Let \(s\) be the number of elements in \(\{b_1, b_2, \ldots, b_k\}\) that are not divisible by \(p\). Considering the set \(\{a_i b_j : 1 \le i \le n, 1 \le j \le k\} \equiv \{1, 2, \ldots, nk\} \pmod{p}\), we get:
   \[
   \left(n - \frac{n}{p}\right)s = \left(kn - \frac{kn}{p}\right) \implies s = k
   \]
   Hence, all elements of \(\{b_1, b_2, \ldots, b_k\}\) are not divisible by \(p\).

   Using that \(\{b_1, b_2, \ldots, b_k\}\) is a complete residue class modulo \(k\), we conclude that any prime dividing \(n\) does not divide \(k\). Hence, \(\gcd(k, n) = 1\).

\(\blacksquare\)

The final answer is \( \boxed{ \gcd(n, k) = 1 } \)