#include<bits/stdc++.h>
using namespace std;
long long p,x_0,y_0,x_1,y_1;
int main(){
cin>>p>>x_0>>y_0>>x_1>>y_1;
if(p==2){
cout<<"NO";
return 0;
}
if(p==1){
if(x_0==x_1||y_0==y_1){
cout<<"YES";
}
else{
cout<<"NO";
}
}
if(p==3){
if(x_0+2==x_1&&y_0+1==y_1||x_0+2==x_1&&y_0-1==y_1||x_0-2==x_1&&y_0+1==y_1||x_0-2==x_1&&y_0-1==y_1||x_0+1==x_1&&y_0+2==y_1||x_0+1==x_1&&y_0-2==y_1||x_0-1==x_1&&y_0+2==y_1||x_0-1==x_1&&y_0-2==y_1){
cout<<"YES";
}
else{
cout<<"NO";
}
}
if(p==4){
if(x_0+2==x_1&&y_0+2==y_1||x_0+2==x_1&&y_0-2==y_1||x_0-2==x_1&&y_0+2==y_1||x_0-2==x_1&&y_0-2==y_1){
cout<<"YES";
}
else{
cout<<"NO";
}
}
return 0;
}