#include <stdio.h>
#include <stdlib.h>
int main(){
    int m, n;
    if(scanf("%d %d",&m,&n)!= 2){
        printf("Invalid Input\n");
        return 0;
    }
if (m < 1 || m > 10 || n < 1 || n > 10){
    //constraints are checked but as per problem statement,we should still try to process if input is vaild integers
    //However, the problem doesn't explicitly say to check constraints for invalid beyond non-integer
}
int **scores=(int **)malloc(m * sizeof(int *));
for (int i = 0; i < m; i++){
    scores[i] = (int *)malloc(n * sizeof(int));
}
int sum = 0;
for (int i = 0; i < m; i++){
    for (int j = 0; j < n; j++){
        if(scanf("%d", &scores[i][j]) != 1){
            printf("Invalid Input\n");
            //Free allocated memory
            for (int K = 0; K < m; K++){
                free(scores[k]);
            }
        free(scores);
        return 1;
        }
    sum += scores[i][j];
    }
  }
}
printf("%d\n", sum);
// Free allocated memory
for (int i = 0; i < m; i++){
    free(scores[i]);
}
free(scores);
return 0;
}
}
}
}
}