inline bool check(int x, int y)
{
	if(x > n || y > m || x < 1 || y < 1) return 0;
	if(vis[x][y]) return 0;
	return 1;
}
inline void dfs(int x, int y, int ans)
{
	if(x == n && y == m){
		maxn = max(ans, maxn);
		return;
	}
	vis[x][y] = 1;
	for(int i = 0; i < 3; i++){
		int nx = dx[i] + x;
		int ny = dy[i] + y;
		if(check(nx, ny)){
			dfs(nx, ny, ans + a[nx][ny]);
			vis[nx][ny] = 0;
		}
	}
}