#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int h,w; cin>>h>>w; vector> use; for(int i = 0;i<=w+1;i++) use.push_back(make_pair(0,i)); for(int i = 0;i<=w+1;i++) use.push_back(make_pair(h+1,i)); for(int i = 0;i<=h+1;i++) use.push_back(make_pair(i,0)); for(int i = 0;i<=h+1;i++) use.push_back(make_pair(i,w+1)); int dx[] = {1,1,1,0,0,-1,-1,-1}; int dy[] = {0,1,-1,1,-1,0,1,-1}; int ans = 0; vector> a(h+2,vector(w+2,0)); for(int i = 1;i<=h;i++) for(int j = 1;j<=w;j++) cin>>a[i][j]; for(int i = 0;i> vis(h+2,vector(w+2,0)); int k = 1; int sum = 0; while(true){ int ni = use[i].first + k * dx[ii]; int nj = use[i].second + k * dy[ii]; if(ni<0||ni>h+1||nj<0||nj>w+1) break; vis[ni][nj]++; sum += a[ni][nj]; k++; } ans = max(ans,sum); for(int j = 0;jh+1||nj<0||nj>w+1) break; k++; if(vis[ni][nj]==0) now += a[ni][nj]; } ans = max(ans,now); } } } } cout<