CodeLab Academy 📞 9936 6696
← List Python · Level 8: Nested loops Code · 80 points ← #742 #744 →

#743. Matrix: Sum of the border elements

You are given a matrix of integers. **Sum of the border elements**. ### Input The first line has n m (the number of rows and columns), each of the next n lines has m integers. ### Output The answer.

Examples

Input
5 2
7 -5
-1 -6
-7 -8
4 -3
1 2
Output
-16
Input
4 4
-3 3 -9 -8
-8 -2 1 5
-8 5 -2 3
0 4 0 2
Output
-19

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!