#include <iostream>
using namespace std;
int main() {
int x [500*500];
int n, m;
cin >> n >> m;
int nm= n*m;
for(int i = 1; i <= nm; i++){
cin >> x[i];
}
int k;
long long int v = 0;
for(int i = 1; i <= nm; i++){
cin >> k;
v+= k*x[i];
}
cout << v << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgeCBbNTAwKjUwMF07CglpbnQgbiwgbTsKCWNpbiA+PiBuID4+IG07CglpbnQgbm09IG4qbTsKCWZvcihpbnQgaSA9IDE7IGkgPD0gbm07IGkrKyl7CgkJY2luID4+IHhbaV07Cgl9CglpbnQgazsKCWxvbmcgbG9uZyBpbnQgdiA9IDA7Cglmb3IoaW50IGkgPSAxOyBpIDw9IG5tOyBpKyspewoJCWNpbiA+PiBrOwoJCXYrPSBrKnhbaV07Cgl9Cgljb3V0IDw8IHYgPDwgZW5kbDsKCXJldHVybiAwOwp9