Let $n$ be a positive integer. Then $\varphi(n)$ is defined as the number of integers in the interval $[0,n-1]$ which are relatively prime to $n$, that is, have no factor greater than $1$ in common with $n$. The function $\varphi$ is called the Euler phi-function.
The following result, due to Euler, generalizes Fermat's (little) Theorem.
Theorem: (Euler) Suppose that $a$ is relatively prime to $n$. Then $a^{\varphi(n)}\equiv 1\pmod{n}$. Equivalently, $n$ divides $a^{\varphi(n)}-1$.
Proofs of Euler's Theorem can be found in any book on Elementary Number Theory. In the Wikipedia article on Fermat's Theorem, you will find, fairly deep into the article, a discussion of how to adapt one of the standard proofs of Fermat's Theorem.
Suppose now that $n$ is divisible neither by $2$ nor by $5$, and let $a=10$. Then $a$ and $n$ are relatively prime, and therefore
$$10^{\varphi(n)}\equiv 1\pmod{n}.$$
For any $k\ge 1$, the number $10^k-1$ has decimal representation that consists only of $9$'s. So we have shown that if $n$ is divisible neither by $2$ nor by $5$, then the number consisting of $\varphi(n)$ $9$'s is divisible by $n$.
That gives you a start on solving the problem you are looking at. To use the result, you might want to look up a formula for $\varphi(n)$ in terms of the prime factorization of $n$.
Now we add more detail. There are some small complications in that in your problem, a specific digit is also given. That makes little difference to the analysis, but does affect numbers $n$ that are divisible by $3$ (when the given digit is $3$, $6$, or $9$) and numbers $n$ divisible by $7$ (when the given digit is $7$).
We address a number-theoretically more important complication. It is quite possible that a number "cheaper" than $\varphi(n)$ will do the job. In our case, the number $n$ is odd. Let
$$n=p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k},$$
where the $p_i$ are distinct odd primes. Let $\lambda$ be the least common multiple of the numbers $(p_i-1)p_i^{a_i-1}$. Then it turns out that the number consisting of $\lambda$ $9$'s is divisible by $n$. For numbers $n$ that are divisible by more than $1$ odd prime, we have $\lambda<\varphi(n)$. For details about these ideas, you might want to look into the Carmichael function.
However, $\varphi(n)$, or the (usually improved) estimate $\lambda$ given in the preceding paragraph, will in general not give you the least exponent that does the job.
But once you have found a number $k$ such that $10^k\equiv 1 \pmod{n}$, any cheaper exponent must be a divisor of $k$. For large $n$, this observation can considerably simplify the search for the cheapest exponent. For enormous $n$, the problem can be exceedingly hard computationally.
Write $a,b,c$ for the sums of each of the three rows. We have $a+b+c=1+\cdots+9=45$. The fact that each row is a multiple of 9 means that $a,b,c\in\{9,18,27,36\}$. So $a,b,c$ are either $27,9,9$ or $18,18,9$, in some order. As $1+2+3+4=10$, the 4-digit term cannot be $9$, so it is $18$ or $27$. But $27$ is not the sum of four consecutive integers, so the third row is $3,4,5,6$ in some order.
We are left with $1,2,7,8,9$ for the other two rows, one adding to $18$ and the other $9$. We cannot reach $18$ with two digits at all or with three digits not using the $9$, so the first row is necessarily one of the following two possibilities: $9,8,1$ in some order, and the middle one $2,7$; or $2,7,9$ in some order and $1,8$. This last case is easily discarded since the only 4-digit product is $279\times18=5022$, which produces the wrong last row.
Looking at the first row, the last digit cannot be $1$ because that would imply a repeated digit. $2$ and $9$ do not fit, because they would put an $8$ in the last row. Actually, if the first row starts with $8$ or $9$, as $819\times27$ already has five digits, we learn that the first number starts with $1$ and that the second one is $27$.
We have $189\times27=5103$, not good, so it has to be $198\times 27=5346$. So the answer to the question is $8+7+6=21$.
Best Answer
Any multiple of 5 ends with either a 0 or a 5. Pick a 0, since 5 isn't 0 or 1. Any multiple of 3 has sum of digits as a multiple of 3. So, it must be 1110.