#include using namespace std; typedef long long int ll; typedef pair P; const ll MOD=1000000007; const ll INF=1000000010; const ll LINF=4000000000000000010LL; const int MAX=310; const double EPS=1e-9; int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; struct pos{int x,y,h;}; int main(){ int n,v,ox,oy;cin>>n>>v>>ox>>oy;ox--;oy--; int c[210][210]; for(int i=0;i>c[i][j]; } } queue q; q.push({0,0,v}); int ans=0; while(!q.empty()){ pos p=q.front(); if(p.x==n-1&&p.y==n-1){ ans=p.h; break; } if(p.x+1