I'll answer the first part of your question. By the same logic you should be able to complete the second part.
Note that we cannot have zero as the last digit (counting digits from right to left) of the number. Hence for the last digit we have only 7 possibilities. Suppose if we fix 0 as the first digit then we have \(7 \times 8^3=3584\) numbers, and the sum of the first digits of all those numbers will add up to \(0\times 7\times 8^3=0\). Similarly if we take 1 as the fist digit the sum of all those numbers will add up to \(1\times 7\times 8^3=3584\). Generally, if we add up all the ones places of the numbers the sum would be,
Similarly if we add up all the tenth places of the numbers the sum would be,