CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #921 #923 →

#922. Minimum path sum

Go from the top-left to the bottom-right of the matrix, moving only right or down. Find the smallest possible sum of the cells you pass. ### Input n m, then n lines of the matrix. ### Output A number.

Examples

Input
5 5
9 7 6 1 7
8 7 0 6 3
7 2 1 7 7
3 7 9 0 9
0 8 6 0 7
Output
37
Input
2 2
1 0
5 7
Output
8

💡 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!