Parallel sum of squares

Go Medium goroutines

Task «Parallel sum of squares»

Write a Go program that reads two integers n and m, then reads n lines, each containing m integers. It is necessary to calculate the sum of squares of all numbers using goroutines. Each line should be processed in a separate goroutine. Output the result to stdout. It is guaranteed that n, m ≤ 100, and the absolute values of the numbers are ≤ 1000.

Input Format

First line: two integers n and m separated by a space. Next n lines, each contains m integers separated by a space.

Output Format

One integer — the sum of squares of all entered numbers.

main.go