Find all triplets $(k, m, n)$ of positive integers having the following property: Square with side length $m$ can be divided into several rectangles of size $1\times k$ and a square with side length $n$.
To solve the problem, we need to determine the conditions under which a square of side length \( m \) can be divided into several rectangles of size \( 1 \times k \) and a square of side length \( n \). 

1. **Understanding the Problem:**
   - We are given a square of side length \( m \).
   - We need to tile this square using rectangles of size \( 1 \times k \) and a square of side length \( n \).
   - The goal is to find all triplets \((k, m, n)\) that satisfy this condition.

2. **Initial Condition:**
   - For the tiling to be possible, the area of the square \( m^2 \) must be equal to the sum of the areas of the \( 1 \times k \) rectangles and the \( n \times n \) square.
   - Let \( x \) be the number of \( 1 \times k \) rectangles used. Then, the total area covered by these rectangles is \( x \cdot k \).
   - The area covered by the \( n \times n \) square is \( n^2 \).

3. **Area Equation:**
   \[
   m^2 = x \cdot k + n^2
   \]

4. **Modulo Condition:**
   - For the tiling to be possible, the remaining area after placing the \( n \times n \) square must be divisible by \( k \).
   - This implies that \( m^2 - n^2 \) must be divisible by \( k \).
   - We can write this condition as:
   \[
   m^2 \equiv n^2 \pmod{k}
   \]
   - This simplifies to:
   \[
   (m - n)(m + n) \equiv 0 \pmod{k}
   \]

5. **Verification with Examples:**
   - Let's verify the given examples:
     - For \((5, 13, 2)\):
       \[
       13^2 = 169, \quad 2^2 = 4
       \]
       \[
       169 - 4 = 165
       \]
       \[
       165 \div 5 = 33 \quad \text{(which is an integer)}
       \]
       - This satisfies the condition.
     - For \((3, 13, 8)\):
       \[
       13^2 = 169, \quad 8^2 = 64
       \]
       \[
       169 - 64 = 105
       \]
       \[
       105 \div 3 = 35 \quad \text{(which is an integer)}
       \]
       - This satisfies the condition.
     - For \((7, 13, 8)\):
       \[
       13^2 = 169, \quad 8^2 = 64
       \]
       \[
       169 - 64 = 105
       \]
       \[
       105 \div 7 = 15 \quad \text{(which is an integer)}
       \]
       - This satisfies the condition.

6. **Conclusion:**
   - The condition \( m \equiv n \pmod{k} \) is not sufficient to determine the tiling.
   - The correct condition is that \( (m - n)(m + n) \) must be divisible by \( k \).

The final answer is \( \boxed{ (m - n)(m + n) \equiv 0 \pmod{k} } \)