#include<bits/stdc++.h>
#define int long long
using namespace std;
    char a[550][550];
    bool used[550][550];
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    int first;
    int starti , startj , endi,endj, n , m;
    bool found;
    int cnt;
    void dfs(int x ,int y)
    {
        used[x][y] = 1;
        if(x == endi and y == endj and first == 1)
        {
                found = true;
                first = 0;
        }
        if(x == endi and y == endj and first == 2)
        {
            cnt++;
            used[endi][endj] = 0;
            first--;
        }
        for(int i = 0 ; i < 4;i++)
        {
            int X = dx[i] + x;
            int Y = dy[i] + y;
            if(X >= 1 and X <= n and Y >= 1 and Y <= m and !used[X][Y] and a[X][Y] != 'X')
            {

                dfs(X,Y);
            }

        }
    }
    main()
    {
        cin >> n >> m;

        for(int i = 1 ; i <= n;i++)
        {
            for(int j = 1 ; j <= m;j++)
            {
                cin >> a[i][j];
            }
        }
        cin >> starti >> startj >> endi >> endj;
        if(a[endi][endj] =='X'){first = 1;a[endi][endj] = '.';}
        else first = 2;
        dfs(starti,startj);
        cout << (found ? "YES" : "NO");

    }


#include<bits/stdc++.h>
#define int long long
using namespace std;
    char a[550][550];
    bool used[550][550];
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    int first;
    int starti , startj , endi,endj, n , m;
    bool found;
    void dfs(int x ,int y)
    {
        used[x][y] = 1;
        if(x == endi and y == endj and first == 1 and endi != starti and endj != startj)
        {
                found = true;
                first = 0;
        }
        if(x == endi and y == endj and first == 2)
        {

            used[endi][endj] = 0;
            first--;
        }
        for(int i = 0 ; i < 4;i++)
        {
            int X = dx[i] + x;
            int Y = dy[i] + y;
            if(X >= 1 and X <= n and Y >= 1 and Y <= m and !used[X][Y] and a[X][Y] != 'X')
            {
                dfs(X,Y);
            }

        }
    }
    main()
    {
        cin >> n >> m;

        for(int i = 1 ; i <= n;i++)
        {
            for(int j = 1 ; j <= m;j++)
            {
                cin >> a[i][j];
            }
        }
        cin >> starti >> startj >> endi >> endj;
        if(a[endi][endj] =='X'){first = 1;a[endi][endj] = '.';}
        else first = 2;
        dfs(starti,startj);
        cout << (found ? "YES" : "NO");

    }


#include<bits/stdc++.h>
#define int long long
using namespace std;
    char a[550][550];
    bool used[550][550];
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    int first;
    int starti , startj , endi,endj, n , m;
    bool found;
    void dfs(int x ,int y)
    {
        used[x][y] = 1;
        if(x == endi and y == endj and first == 1)
        {
            found = true;
            return;
        }
        if(x == endi and y == endj and first == 2)
        {

            used[endi][endj] = 0;
            first--;
        }
        for(int i = 0 ; i < 4;i++)
        {
            int X = dx[i] + x;
            int Y = dy[i] + y;
            if(X >= 1 and X <= n and Y >= 1 and Y <= m and !used[X][Y] and a[X][Y] != 'X')
            {
                dfs(X,Y);
            }

        }
    }
    main()
    {
        cin >> n >> m;
        for(int i = 1 ; i <= n;i++)
        {
            for(int j = 1 ; j <= m;j++)
            {
                cin >> a[i][j];
            }
        }
        cin >> starti >> startj >> endi >> endj;
        if(a[endi][endj] =='X'){first = 1;a[endi][endj] = '.';}
        else first = 2;
        dfs(starti,startj);
        cout << (found ? "YES" : "NO");

    }


#include<bits/stdc++.h>
#define int long long
using namespace std;
    char a[550][550];
    bool used[550][550];
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    int first;
    int starti , startj , endi,endj, n , m;
    bool found;
    void dfs(int x ,int y)
    {
        used[x][y] = 1;
        if(x == endi and y == endj and first == 1)
        {
            return cout <<"YES",0;
        }
        if(x == endi and y == endj and first == 2)
        {

            used[endi][endj] = 0;
            first--;
        }
        for(int i = 0 ; i < 4;i++)
        {
            int X = dx[i] + x;
            int Y = dy[i] + y;
            if(X >= 1 and X <= n and Y >= 1 and Y <= m and !used[X][Y] and a[X][Y] != 'X')
            {
                dfs(X,Y);
            }

        }
    }
    main()
    {
        cin >> n >> m;
        for(int i = 1 ; i <= n;i++)
        {
            for(int j = 1 ; j <= m;j++)
            {
                cin >> a[i][j];
            }
        }
        cin >> starti >> startj >> endi >> endj;
        if(a[endi][endj] =='X'){first = 1;a[endi][endj] = '.';}
        else first = 2;
        dfs(starti,startj);
        puts("NO");

    }


#include<bits/stdc++.h>
#define int long long
using namespace std;
    char a[550][550];
    bool used[550][550];
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    int first;
    int starti , startj , endi,endj, n , m;
    bool found;
    void dfs(int x ,int y)
    {
        used[x][y] = 1;

        if(x == endi and y == endj and first == 2)
        {

            used[endi][endj] = 0;
            first--;
        }
        for(int i = 0 ; i < 4;i++)
        {
            int X = dx[i] + x;
            int Y = dy[i] + y;
            if(X >= 1 and X <= n and Y >= 1 and Y <= m and !used[X][Y] and a[X][Y] != 'X')
            {
                if(x == endi and y == endj and first == 1)
                {
                found = true;
                }
                dfs(X,Y);
            }

        }
    }
    main()
    {
        cin >> n >> m;

        for(int i = 1 ; i <= n;i++)
        {
            for(int j = 1 ; j <= m;j++)
            {
                cin >> a[i][j];
            }
        }
        cin >> starti >> startj >> endi >> endj;
        if(a[endi][endj] =='X'){first = 1;a[endi][endj] = '.';}
        else first = 2;
        dfs(starti,startj);
        cout << (found ? "YES" : "NO");

    }


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef struct lol {
        int x,y;
}troll;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,X,Y,st,dr,viz[505][505];
bool u;
char c;
troll q[250005];

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  for(i=0;i<=n+1;++i) viz[i][0]=viz[i][m+1]=2;

  cin>>x>>y>>X>>Y;

  q[1].x=x; q[1].y=y;
  for(st=dr=1;st<=dr && !u;++st)
   for(++viz[q[st].x][q[st].y],i=0;i<4 && !u;++i)
   {
     x=q[st].x+dx[i]; y=q[st].y+dy[i];
     if(x==X && y==Y) u=1,++viz[x][y];
     else if(!viz[x][y]) q[++dr].x=x,q[dr].y=y;
   }

  if(!u) return cout<<"NO\n",0;

  if(viz[X][Y]==2) cout<<"YES\n";
  else {
         for(u=i=0;i<4 && !u;++i)
         {
           x=X+dx[i]; y=Y+dy[i];
           if(!viz[x][y]) u=1;
         }
         cout<<(u ? "YES\n":"NO\n");
       }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef struct lol {
        int x,y;
}troll;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,X,Y,st,dr,viz[505][505];
bool u;
char c;
troll q[250005];

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  for(i=0;i<=n+1;++i) viz[i][0]=viz[i][m+1]=2;
  for(i=0;i<=m+1;++i) viz[0][i]=viz[n+1][i]=2;

  cin>>x>>y>>X>>Y;

  q[1].x=x; q[1].y=y;
  for(st=dr=1;st<=dr && !u;++st)
   for(++viz[q[st].x][q[st].y],i=0;i<4 && !u;++i)
   {
     x=q[st].x+dx[i]; y=q[st].y+dy[i];
     if(x==X && y==Y) u=1,++viz[x][y];
     else if(!viz[x][y]) q[++dr].x=x,q[dr].y=y,++viz[x][y];
   }

  if(!u) return cout<<"NO\n",0;

  if(viz[X][Y]==2) cout<<"YES\n";
  else {
         for(u=i=0;i<4 && !u;++i)
         {
           x=X+dx[i]; y=Y+dy[i];
           if(!viz[x][y]) u=1;
         }
         cout<<(u ? "YES\n":"NO\n");
       }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef struct lol {
        int x,y;
}troll;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,X,Y,st,dr,viz[505][505];
bool u;
char c;
troll q[500005];

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  for(i=0;i<=n+1;++i) viz[i][0]=viz[i][m+1]=2;
  for(i=0;i<=m+1;++i) viz[0][i]=viz[n+1][i]=2;

  cin>>x>>y>>X>>Y;

  q[1].x=x; q[1].y=y; u=(x==X && y==Y);
  for(st=dr=1;st<=dr && !u;++st)
   for(i=0;i<4 && !u;++i)
   {
     x=q[st].x+dx[i]; y=q[st].y+dy[i];
     if(x==X && y==Y) u=1,++viz[x][y];
     else if(!viz[x][y]) q[++dr].x=x,q[dr].y=y,++viz[x][y];
   }

  if(!u) return cout<<"NO\n",0;

  if(viz[X][Y]==2) cout<<"YES\n";
  else {
         for(u=i=0;i<4 && !u;++i)
         {
           x=X+dx[i]; y=Y+dy[i];
           if(!viz[x][y]) u=1;
         }
         cout<<(u ? "YES\n":"NO\n");
       }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,q,w,viz[505][505];
bool u;
char c;

void dfs(int x,int y) {
     if(!x || !y || x>n || y>m || viz[x][y]>2 || u) return ;

     if(x==q && y==w) u=1,++viz[x][y];
     if(u || viz[x][y]) return ;
     ++viz[x][y];

     for(int i=0;i<4 && !u;++i) dfs(x+dx[i],y+dy[i]);
}

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  cin>>x>>y>>q>>w;

  viz[x][y]=0; dfs(x,y);

  if(viz[q][w]==2) cout<<"YES\n";
  else if(!viz[q][w]) cout<<"NO\n";
       else {
              for(u=i=0;i<4 && !u;++i)
              {
                x=q+dx[i]; y=w+dy[i];
                if(x && y && x<=n && y<=m && !viz[x][y]) u=1;
              }
              cout<<(u ? "YES":"NO")<<'\n';
            }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,q,w,viz[505][505];
bool u;
char c;

void dfs(int x,int y) {
     if(!x || !y || x>n || y>m || viz[x][y]>1 || u) return ;

     ++viz[x][y];
     if(x==q && y==w) u=1;
     if(u) return ;
     if(viz[x][y]==2) return ;

     for(int i=0;i<4 && !u;++i) dfs(x+dx[i],y+dy[i]);
}

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  cin>>x>>y>>q>>w;

  viz[x][y]=0; dfs(x,y);

  if(viz[q][w]==2) cout<<"YES\n";
  else if(!viz[q][w]) cout<<"NO\n";
       else {
              for(u=i=0;i<4 && !u;++i)
              {
                x=q+dx[i]; y=w+dy[i];
                if(x && y && x<=n && y<=m && !viz[x][y]) u=1;
              }
              cout<<(u ? "YES":"NO")<<'\n';
            }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,q,w,viz[505][505];
bool u;
char c;

void dfs(int x,int y) {
     if(!x || !y || x>n || y>m || viz[x][y]>1 || u) return ;

     ++viz[x][y];
     if(x==q && y==w) u=1;
     if(u) return ;
     if(viz[x][y]==2) return ;

     for(i=0;i<4 && !u;++i) dfs(x+dx[i],y+dy[i]);
}

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  cin>>x>>y>>q>>w;

  viz[x][y]=0; dfs(x,y);

  if(viz[q][w]==2) cout<<"YES\n";
  else if(!viz[q][w]) cout<<"NO\n";
       else {
              for(u=i=0;i<4 && !u;++i)
              {
                x=q+dx[i]; y=w+dy[i];
                if(x && y && x<=n && y<=m && !viz[x][y]) u=1;
              }
              cout<<(u ? "YES":"NO")<<'\n';
            }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef struct lol {
        int x,y;
}troll;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,X,Y,st,dr,viz[505][505];
bool u;
char c;
troll q[250005];

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  for(i=0;i<=n+1;++i) viz[i][0]=viz[i][m+1]=2;
  for(i=0;i<=m+1;++i) viz[0][i]=viz[n+1][i]=2;

  cin>>x>>y>>X>>Y;

  if(n==1 && m==1) return cout<<"NO\n",0;
  if(x==X && y==Y) return cout<<"YES\n",0;

  q[1].x=x; q[1].y=y;
  for(st=dr=1;st<=dr && !u;++st)
   for(++viz[q[st].x][q[st].y],i=0;i<4 && !u;++i)
   {
     x=q[st].x+dx[i]; y=q[st].y+dy[i];
     if(x==X && y==Y) u=1,++viz[x][y];
     else if(!viz[x][y]) q[++dr].x=x,q[dr].y=y,++viz[x][y];
   }

  if(!u) return cout<<"NO\n",0;

  if(viz[X][Y]==2) cout<<"YES\n";
  else {
         for(u=i=0;i<4 && !u;++i)
         {
           x=X+dx[i]; y=Y+dy[i];
           if(!viz[x][y]) u=1;
         }
         cout<<(u ? "YES\n":"NO\n");
       }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef struct lol {
        int x,y;
}troll;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,X,Y,st,dr,viz[505][505];
bool u;
char c;
troll q[500005];

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  for(i=0;i<=n+1;++i) viz[i][0]=viz[i][m+1]=2;
  for(i=0;i<=m+1;++i) viz[0][i]=viz[n+1][i]=2;

  cin>>x>>y>>X>>Y;

  q[1].x=x; q[1].y=y; u=(x==X && y==Y);
  for(st=dr=1;st<=dr && !u;++st)
   for(++viz[q[st].x][q[st].y],i=0;i<4 && !u;++i)
   {
     x=q[st].x+dx[i]; y=q[st].y+dy[i];
     if(x==X && y==Y) u=1,++viz[x][y];
     else if(!viz[x][y]) q[++dr].x=x,q[dr].y=y;
   }

  if(!u) return cout<<"NO\n",0;

  if(viz[X][Y]==2) cout<<"YES\n";
  else {
         for(u=i=0;i<4 && !u;++i)
         {
           x=X+dx[i]; y=Y+dy[i];
           if(!viz[x][y]) u=1;
         }
         cout<<(u ? "YES\n":"NO\n");
       }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

const int dx[]={-1,1,0,0};
const int dy[]={0,0,-1,1};

int n,m,i,j,x,y,q,w,viz[505][505];
bool u;
char c;

void dfs(int x,int y) {
     if(!x || !y || x>n || y>m || viz[x][y]>1 || u) return ;

     ++viz[x][y];
     if(x==q && y==w) u=1;
     if(u) return ;
     if(viz[x][y]==2) return ;

     for(int i=0;i<4 && !u;++i) dfs(x+dx[i],y+dy[i]);
}

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  cin>>x>>y>>q>>w;

  viz[x][y]=0; dfs(x,y);

  if(!u) return cout<<"NO\n",0;

  if(viz[q][w]>=2) cout<<"YES\n";
  else if(!viz[q][w]) cout<<"NO\n";
       else {
              for(u=i=0;i<4 && !u;++i)
              {
                x=q+dx[i]; y=w+dy[i];
                if(x && y && x<=n && y<=m && !viz[x][y]) u=1;
              }
              cout<<(u ? "YES":"NO")<<'\n';
            }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef struct lol {
        int x,y;
}troll;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,X,Y,st,dr,viz[505][505];
bool u;
char c;
troll q[250005];

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  for(i=0;i<=n+1;++i) viz[i][0]=viz[i][m+1]=2;
  for(i=0;i<=m+1;++i) viz[0][i]=viz[n+1][i]=2;

  cin>>x>>y>>X>>Y;

  if(x==X && y==Y) return cout<<"YES\n",0;

  q[1].x=x; q[1].y=y;
  for(st=dr=1;st<=dr && !u;++st)
   for(++viz[q[st].x][q[st].y],i=0;i<4 && !u;++i)
   {
     x=q[st].x+dx[i]; y=q[st].y+dy[i];
     if(x==X && y==Y) u=1,++viz[x][y];
     else if(!viz[x][y]) q[++dr].x=x,q[dr].y=y,++viz[x][y];
   }

  if(!u) return cout<<"NO\n",0;

  if(viz[X][Y]==2) cout<<"YES\n";
  else {
         for(u=i=0;i<4 && !u;++i)
         {
           x=X+dx[i]; y=Y+dy[i];
           if(!viz[x][y]) u=1;
         }
         cout<<(u ? "YES\n":"NO\n");
       }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef struct lol {
        int x,y;
}troll;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,X,Y,st,dr,viz[505][505];
bool u;
char c;
troll q[250005];

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  for(i=0;i<=n+1;++i) viz[i][0]=viz[i][m+1]=2;
  for(i=0;i<=m+1;++i) viz[0][i]=viz[n+1][i]=2;

  cin>>x>>y>>X>>Y;

  q[1].x=x; q[1].y=y; u=(x==X && y==Y);
  for(st=dr=1;st<=dr && !u;++st)
   for(++viz[q[st].x][q[st].y],i=0;i<4 && !u;++i)
   {
     x=q[st].x+dx[i]; y=q[st].y+dy[i];
     if(x==X && y==Y) u=1,++viz[x][y];
     else if(!viz[x][y]) q[++dr].x=x,q[dr].y=y;
   }

  if(!u) return cout<<"NO\n",0;

  if(viz[X][Y]==2) cout<<"YES\n";
  else {
         for(u=i=0;i<4 && !u;++i)
         {
           x=X+dx[i]; y=Y+dy[i];
           if(!viz[x][y]) u=1;
         }
         cout<<(u ? "YES\n":"NO\n");
       }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,q,w,viz[505][505];
bool u;
char c;

void dfs(int x,int y) {
     if(!x || !y || x>n || y>m || viz[x][y]>1 || u) return ;

     ++viz[x][y];
     if(x==q && y==w) u=1;
     if(u) return ;
     if(viz[x][y]==2) return ;

     for(i=0;i<4;++i) dfs(x+dx[i],y+dy[i]);
}

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  cin>>x>>y>>q>>w;

  viz[x][y]=0; dfs(x,y);

  if(viz[q][w]==2) cout<<"YES\n";
  else if(!viz[q][w]) cout<<"NO\n";
       else {
              for(u=i=0;i<4 && !u;++i)
              {
                x=q+dx[i]; y=w+dy[i];
                if(x && y && x<=n && y<=m && !viz[x][y]) u=1;
              }
              cout<<(u ? "YES":"NO")<<'\n';
            }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

typedef struct lol {
        int x,y;
}troll;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,X,Y,st,dr,viz[505][505];
bool u;
char c;
troll q[250005];

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  for(i=0;i<=n+1;++i) viz[i][0]=viz[i][m+1]=2;
  for(i=0;i<=m+1;++i) viz[0][i]=viz[n+1][i]=2;

  cin>>x>>y>>X>>Y;

  q[1].x=x; q[1].y=y; u=(x==X && y==Y);
  for(st=dr=1;st<=dr && !u;++st)
   for(++viz[q[st].x][q[st].y],i=0;i<4 && !u;++i)
   {
     x=q[st].x+dx[i]; y=q[st].y+dy[i];
     if(x==X && y==Y) u=1,++viz[x][y];
     else if(!viz[x][y]) q[++dr].x=x,q[dr].y=y,++viz[x][y];
   }

  if(!u) return cout<<"NO\n",0;

  if(viz[X][Y]==2) cout<<"YES\n";
  else {
         for(u=i=0;i<4 && !u;++i)
         {
           x=X+dx[i]; y=Y+dy[i];
           if(!viz[x][y]) u=1;
         }
         cout<<(u ? "YES\n":"NO\n");
       }

 return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int n,m,i,j,x,y,q,w,viz[505][505];
bool u;
char c;

void dfs(int x,int y) {
     if(!x || !y || x>n || y>m || viz[x][y]>1 || u) return ;

     ++viz[x][y];
     if(x==q && y==w) u=1;
     if(u) return ;
     if(viz[x][y]==2) return ;

     for(int i=0;i<4 && !u;++i) dfs(x+dx[i],y+dy[i]);
}

int main()
{
  ios_base::sync_with_stdio(0);

  cin>>n>>m;
  for(i=1;i<=n;++i)
   for(j=1;j<=m;++j)
   {
     cin>>c;
     viz[i][j]=((c=='.') ? 0:1);
   }

  cin>>x>>y>>q>>w;

  viz[x][y]=0; dfs(x,y);

  if(!u) return cout<<"NO\n",0;

  if(viz[q][w]>=2) cout<<"YES\n";
  else if(!viz[q][w]) cout<<"NO\n";
       else {
              for(u=i=0;i<4 && !u;++i)
              {
                x=q+dx[i]; y=w+dy[i];
                if(x && y && x<=n && y<=m && !viz[x][y]) u=1;
              }
              cout<<(u ? "YES":"NO")<<'\n';
            }

 return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(r==r2 && c==c2) return true;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(f[r+dx[i]][c+dy[i]]==1) continue;
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	if(count>=2)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(r+dx[i]==r2 && c+dy[i]==c2) return true;
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;

	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 1;
	int minc=2;
	if(r1==r2 && c1==c2){
		if(board[r1][c1]=='.')
			minc=2;
		else
			minc=1;
	}
	if(abs(r1-r2)+abs(c1-c2)==1){
		if(board[r2][c2]=='.')
			minc=1;
		else
			minc=0,count=0;
	}
	cerr <<count << ">=?"<<minc<<"\n";
	if(count>=minc)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r==r2 && c==c2) return true;
	if(r<0||c<0 || r>=n || c>=m) return false;
	f[r][c]=1;
	REP(i,4){
		if(dfs(r+dx[i],c+dx[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	if(count>=2)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r==r2 && c==c2) return true;
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(board[r][c] == 'X') return false;
	f[r][c]=1;
	REP(i,4){
		if(f[r+dx[i]][c+dy[i]]==1) continue;
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	if(count>=2)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(r==r2 && c==c2) return true;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;

	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	int minc=2;
	if(r1==r2 && c1==c2){
		if(board[r1][c1]=='.')
			minc=2;
		else
			minc=1;
	}
	if(abs(r1-r2)+abs(c1-c2)==1){
		if(board[r2][c2]=='.')
			minc=1;
		else
			minc=0;
	}
	//cerr <<count << ">=?"<<minc<<"\n";
	if(count>=minc)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(r==r2 && c==c2) return true;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;

	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	REP(i,4){
		int r = r2+dx[i], c = c2+dy[i];
		if(r<0||c<0 || r>=n || c>=m) continue;
		if(board[r][c] == '.') count++;
	}
	int minc=2;
	if(r1==r2 && c1==c2){
		if(board[r1][c1]=='.')
			minc=2;
		else
			minc=1;
	}
	if(abs(r1-r2)+abs(c1-c2)==1){
		if(board[r2][c2]=='.')
			minc=1;
		else
			minc=0;
	}
	cerr <<count << ">=?"<<minc<<"\n";
	if(count>=minc)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(r==r2 && c==c2) return true;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;

	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	int minc=2;
	if(r1==r2 && c1==c2){
		if(board[r1][c1]=='.')
			minc=2;
		else
			minc=1;
	}
	if(abs(r1-r2)+abs(c1-c2)==1){
		if(board[r2][c2]=='.')
			minc=1;
		else
			minc=0;
	}
	if(count>=minc)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(r==r2 && c==c2) return true;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	if(count>=2)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(r==r2 && c==c2) return true;
	f[r][c]=1;
	REP(i,4){
		if(f[r+dx[i]][c+dy[i]]==1) continue;
		if(board[r+dx[i]][c+dy[i]]=='X') continue;
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	if(count>=2)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r==r2 && c==c2) return true;
	if(r<0||c<0 || r>=n || c>=m) return false;
	f[r][c]=1;
	REP(i,4){
		if(f[r+dx[i]][c+dy[i]]==1) continue;
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	if(count>=2)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(r==r2 && c==c2) return true;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;

	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	int minc=2;
	if(r1==r2 && c1==c2){
		minc = board[r1][r2] == 'X' ? 1 : 2;
	}
	if(count>=minc)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(r+dx[i]==r2 && c+dy[i]==c2) return true;
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;r2--;c1--;c2--;

	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 1;
	int minc=board[r2][c2]=='X'?1:2;
	if(r1==r2 && c1==c2){
		if(board[r1][c1]=='.')
			minc=2;
		else
			minc=1;
	}
	if(abs(r1-r2)+abs(c1-c2)==1){
		if(board[r2][c2]=='.')
			minc=1;
		else
			minc=0,count=0;
	}
	if(count>=minc)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(r==r2 && c==c2) return true;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;

	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	int minc=2;
	if(r1==r2 && c1==c2){
		minc = board[r1][r2] == 'X' ? 1 : 2;
	}
	if(count>=2)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include <iostream>
#include <numeric>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <stack>
#include <string>
#include <sstream>
#include <math.h>

#define REP(i,n) for(int i = 0; i<(n); i++)
#define ITER(i,v) for(auto i : v)
#define INF 1000000000
#define F(v) (v).begin(), (v).end()
#ifdef DEBUG
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

using namespace std;

template <class T>
using priority_queue_asc =  priority_queue<T,vector<T>, greater<T> >;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<bool> vb;

array<array<char,500>,500> board;
array<array<int,500>,500> f;
int n,m;

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};

int r1,c1,r2,c2;
bool dfs(int r, int c){
	if(r<0||c<0 || r>=n || c>=m) return false;
	if(f[r][c]==1) return false;
	if(r==r2 && c==c2) return true;
	if(board[r][c] == 'X' && !(r==r1 && c == c1)) return false;
	f[r][c]=1;
	REP(i,4){
		if(dfs(r+dx[i],c+dy[i])) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	REP(i,500) f[i].fill(0);
	REP(i,n){
		cin >> ws;
		REP(j,m)
			cin >> board[i][j];
	}
	cin >> r1 >> c1 >> r2 >> c2;

	r1--;r2--;c1--;c2--;
	if(!dfs(r1,c1)){
		cout << "NO\n";
		return 0;
	}

	// if '.', check for 2 neighbouring '.'
	int count=0;
	if(board[r2][c2]=='.'){
		REP(i,4){
			int r = r2+dx[i], c = c2+dy[i];
			if(r<0||c<0 || r>=n || c>=m) continue;
			if(board[r][c] == '.') count++;
		}
	} else count = 4;
	int minc=2;
	if(r1==r2 && c1==c2){
		if(board[r1][c1]=='.')
			minc=2;
		else
			minc=1;
	}
	if(abs(r1-r2)+abs(c1-c2)==1){
		if(board[r1][c1]=='.')
			minc=1;
		else
			minc=0;
	}
	if(count>=minc)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


#include<iostream>
#include<queue>
#include<cstdio>
using namespace std;

const int maxn=505;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct node{
    int r,c;
    node(int rr=0,int cc=0):r(rr),c(cc){}
};
int n,m;
int r0,c0,r1,c1;
char g[maxn][maxn];
void bfs(){
    queue<node> que;
    que.push(node(r0,c0));
    while(!que.empty()){
        node t=que.front();
        que.pop();
        int r=t.r;
        int c=t.c;
        for(int k=0;k<4;++k){
            int x=dx[k]+r;
            int y=dy[k]+c;
            if(x<0||x>=n||y<0||y>=m) continue;
            if('X'==g[x][y] && x==r1 && y==c1){
                puts("YES");
                return;
            }
            else if('.'==g[x][y]){
                g[x][y]='X';
                que.push(node(x,y));
            }
        }
    }
    puts("NO");
}

int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)
		scanf("%s",g[i]);
    scanf("%d%d%d%d",&r0,&c0,&r1,&c1);
    --r0,--c0,--r1,--c1;
    bfs();
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int n,m;
struct F{
    int x;
    int y;
}st;
int mp[505][505];
int x[4]={-1,1,0,0};
int y[4]={0,0,1,-1};
queue <F> q;
int bx,by,ex,ey;
void bfs()
{
    F t,tt;
    mp[bx][by]=2;
    while (!q.empty())
    {
        t=q.front();
        q.pop();
        for(int i=0;i<4;i++)
        {
            tt.x=t.x+x[i];
            tt.y=t.y+y[i];
            if (tt.x==ex&&tt.y==ey&&mp[tt.x][tt.y]==2)
            {
                cout<<"YES"<<endl;
                exit(0);
            }
            if (tt.x>=1&&tt.x<=n&&tt.y>=1&&tt.y<=m&&mp[tt.x][tt.y]==1)
            {
                mp[tt.x][tt.y]=2;
                q.push(tt);
            }
        }
    }
    cout<<"NO"<<endl;
}
int main()
{
    int i,j;
    char c;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        for (j=1;j<=m;j++)
        {
            cin>>c;
            if (c=='.')
            mp[i][j]=1;
            else
            mp[i][j]=2;
        }
    }
    cin>>bx>>by>>ex>>ey;
    st.x=bx;
    st.y=by;
    q.push(st);
    bfs();
    return 0;
}


#include <cstdio>
#define reg register
using namespace std;

int n, m, xa, xb, ya, yb, dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
char a[505][505];
bool vis[505][505], flag;

inline void dfs(int x, int y, int c, int f){
    if(x != xb || y != yb)
        vis[x][y] = 1;
    if(x == xb && y == yb && f == 1){
        c ++;
        if(c == 1 && a[xb][yb] == 'X'){
            flag = 1;
            return ;
        }
        if(c == 2 && a[xb][yb] == '.'){
            flag = 1;
            return ;
        }
    }
    int nex, ney;
    for(reg int i = 0; i < 4; i++){
        nex = x + dir[i][0];
        ney = y + dir[i][1];
        if(nex < 1 || nex > n || ney < 1 || ney > m || vis[nex][ney])
            continue;
        if(nex != xb || ney != yb)
            if(a[nex][ney] == 'X')
                continue;
        dfs(nex, ney, c, 1);
        if(flag)
            return ;
    }
}

int main(){
    scanf("%d%d", &n, &m);
    for(reg int i = 1; i <= n; i++){
        scanf("\n");
        for(reg int j = 1; j <= m; j++){
            scanf("%c", &a[i][j]);
        }
    }
    scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
    dfs(xa, ya, 0, 0);
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <cstdio>
#define reg register
using namespace std;

int n, m, xa, xb, ya, yb, dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
char a[505][505];
bool vis[505][505], flag;

inline void dfs(int x, int y, int c, int f){
    if(x != xb || y != yb)
        vis[x][y] = 1;
    if(x == xb && y == yb && f == 1){
        c ++;
        if(c == 1 && a[xb][yb] == 'X'){
            flag = 1;
            return ;
        }
        if(c == 2 && a[xb][yb] == '.'){
            flag = 1;
            return ;
        }
    }
    int nex, ney;
    for(reg int i = 0; i < 4; i++){
        nex = x + dir[i][0];
        ney = y + dir[i][1];
        if(nex < 1 || nex > n || ney < 1 || ney > m || vis[nex][ney])
            continue;
        if(nex != xb || ney != yb)
            if(a[nex][ney] == 'X')
                continue;
        dfs(nex, ney, c, 1);
        if(flag)
            return ;
    }
    vis[x][y] = 0;
}

int main(){
    scanf("%d%d", &n, &m);
    for(reg int i = 1; i <= n; i++){
        scanf("\n");
        for(reg int j = 1; j <= m; j++){
            scanf("%c", &a[i][j]);
        }
    }
    scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
    dfs(xa, ya, 0, 0);
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
#include<string.h>
char c[600][600];
int s[4][2]= {{1,0},{-1,0},{0,-1},{0,1}};
struct node
{
    int x,y;
} q[600*600];
int main()
{
    int n,m,sx,sy,tx,ty,flog=0,i;
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++)
    {
        scanf("%s",c[i]);
    }
    scanf("%d %d",&sx,&sy);
    scanf("%d %d",&tx,&ty);
    sx--;
    sy--;
    tx--;
    ty--;
    if(sx==tx&&sy==ty)
    {
        printf("YES\n");
    }
    int tail,head,x,y;
    tail=head=0;
    q[tail].x=sx;
    q[tail].y=sy;
    tail++;
    while(head<tail)
    {
        for(i=0; i<4; i++)
        {
            x=q[head].x+s[i][0];
            y=q[head].y+s[i][1];
            if(x<0||y<0||x>=n||y>=m)
                continue;
            if(c[x][y]=='X'&&x==tx&&y==ty)
            {
                flog=1;
                break;
            }
            else if(c[x][y]=='.')
            {
                q[tail].x=x;
                q[tail].y=y;
                c[x][y]='X';
                tail++;
            }
        }
        head++;
        if(flog==1)
            break;
    }
    if(flog==1)
        printf("YES\n");
    else
        printf("NO\n");;
}


#include<bits/stdc++.h>
using namespace std;
const int d[4][2]={{0,-1},{0,1},{1,0},{-1,0}};
int n,m,vis[666][666],sx,sy,ex,ey;
bool dfs(int nx,int ny){
    for(int i=0;i<4;i++){
        int tx=nx+d[i][0],ty=ny+d[i][1];
        if(tx>=1&&tx<=n&&ty>=1&&ty<=m){
            if(vis[tx][ty]){
                if(tx==ex&&ty==ey)return 1;
                else continue;
            }else{
                vis[tx][ty]=1;
                if(dfs(tx,ty))return 1;
            }
		}
    }
    return 0;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
	memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            char a;cin>>a;
			if(a=='X')vis[i][j]=1;
        }
	cin>>sx>>sy>>ex>>ey;
	cout<<dfs(sx,sy)?"YES":"NO";
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
#define MAXN 505
typedef long long LL;
typedef pair<int,int> pii;
#define gc() getchar()
template<typename _T>
void read(_T &x){
	_T f=1;x=0;char s=gc();
	while(s>'9'||s<'0'){if(s=='-')f=-1;s=gc();}
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+(s^48);s=gc();}
	x*=f;
}
int n,m;
int dx[5]={0,0,1,-1};
int dy[5]={1,-1,0,0};
bool maze[MAXN][MAXN];
int vis[MAXN][MAXN];
struct ming{
	int x,y;
	ming(){}
	ming(int X,int Y){x=X;y=Y;}
}s,e;
queue<ming> q;
signed main(){
	read(n);read(m);
	for(int i=1;i<=n;i++){
		scanf("\n");
		for(int j=1;j<=m;j++){
			char c;scanf("%c",&c);
			maze[i][j]=(c=='X');
		}
	}
	read(s.x);read(s.y);read(e.x);read(e.y);
	int sum=0;
	for(int i=0;i<4;i++){
		int tx=e.x+dx[i];
		int ty=e.y+dy[i];
		if(tx<1||ty<1||tx>n||ty>m)continue;
		if(tx==s.x&&ty==s.y)sum++;
		sum+=(!maze[tx][ty]);
	}
	if(s.x==e.x&&s.y==e.y){puts(sum<1?"NO":"YES");return 0;}
	if(!maze[e.x][e.y]&&sum<2){puts("NO");return 0;}
	q.push(s);q.push(e);vis[s.x][s.y]=1;vis[e.x][e.y]=-1;
	while(!q.empty()){
		ming t=q.front();q.pop();
		for(int i=0;i<4;i++){
			int tx=t.x+dx[i];
			int ty=t.y+dy[i];
			if(tx<1||ty<1||tx>n||ty>m)continue;
			if(maze[tx][ty]&&(tx!=e.x||ty!=e.y))continue;
			if(vis[tx][ty]==vis[t.x][t.y])continue;
			if(vis[tx][ty]==-vis[t.x][t.y]){puts("YES");return 0;}
			vis[tx][ty]=vis[t.x][t.y];q.push(ming(tx,ty));
		}
	}
	puts("NO");
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

#define M 505

int n, m, r[5], c[5], flag[M][M];
int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
char G[M][M];

bool check_end (int x, int y){
    if (G[x][y] == 'X')
        return 1;
    else{
        if (G[x + 1][y] == '.' || G[x - 1][y] == '.' || G[x][y + 1] == '.' || G[x][y - 1] == '.')
            return 1;
    }
    return 0;
}
bool check_in (int x, int y){
    if (x >= 1 && x <= n && y >= 1 && y <= m && G[x][y] != 'X' && ! flag[x][y])
        return 1;
    return 0;
}
bool dfs (int x, int y){
    for (int i = 0; i < 4; i ++){
        int tox = x + dir[i][0];
        int toy = y + dir[i][1];
        if (tox == r[2] && toy == c[2]){
            if (check_end (tox, toy))
                return 1;
            return 0;
        }
        if (check_in (tox, toy)){
            G[tox][toy] = 'X';
            if (dfs (tox, toy))
                return 1;
            flag[tox][toy] = 1;
            G[tox][toy] = '.';
        }
    }
    return 0;
}
int main (){
    scanf ("%d %d", &n, &m);
    for (int i = 1; i <= n; i ++){
        scanf ("\n");
        for (int j = 1; j <= m; j ++)
            scanf ("%c", &G[i][j]);
    }
    scanf ("%d %d %d %d", &r[1], &c[1], &r[2], &c[2]);
    if (dfs (r[1], c[1]))
        printf ("YES\n");
    else
        printf ("NO\n");
    return 0;
}


#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
int n,m,r1,c1,r2,c2,kase,vis[507][507];
char mp[507][507];
const int fx[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
struct point{
    int x,y,v;
    char c;
    inline point operator=(const point&a){
       x=a.x;y=a.y;v=a.v;c=a.c;
       return *this;
    }
    point(int x1,int y1,int c1,int v1){
        x=x1;y=y1;c=c1;v=v1;
    }
};
queue<point>q;
int main(){
    ios::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)cin>>mp[i][j];
    cin>>r1>>c1>>r2>>c2;
    point a(r1,c1,mp[r1][c1],0);
    q.push(a);
    while(1){
        if(q.empty())break;
        point top=q.front();q.pop();
        if(top.c=='X'&&top.x!=r1&&top.y!=r2)continue;
        top.v++;vis[top.x][top.y]++;
        mp[top.x][top.y]='X';top.c='X';
        for(int i=0;i<4;i++){
            point tmp(top.x+fx[i][0],top.y+fx[i][1],mp[top.x+fx[i][0]][top.y+fx[i][1]],vis[top.x+fx[i][0]][top.y+fx[i][1]]);
            if(tmp.x==r2&&tmp.y==c2&&tmp.c=='X'){
                cout<<"YES";
                return 0;
            }
            bool b=tmp.x>0&&tmp.y>0&&tmp.x<=n&&tmp.y<=m&&tmp.c=='.'&&tmp.v<5;
            if(b)q.push(tmp);
        }
    }
    cout<<"NO";
}


#include<iostream>
#include<cstring>
#include<cstdlib>
#define reg register
#define rep(i,j,k) for(reg int i=j;i<=k;++i)
#define MAXN 509
using namespace std;
int n,m,t1,c1,t2,c2;
int dx[5]={0,1,-1,0,0},dy[5]={0,0,0,1,-1};
bool flag=true,vis[MAXN][MAXN];
inline void check(void)
{
	if (vis[t2+1][c2]||vis[t2-1][c2]||vis[t2][c2+1]||vis[t2][c2-1]||(!vis[t2][c2]&&!(t1==t2&&c1==c2&&flag))) cout<<"YES\n",exit(0);
	return;
}
inline void dfs(reg int x,reg int y)
{
//  cout<<x<<" "<<y<<endl<<endl;
	if (x==t2&&y==c2) check();
	if (!vis[x][y]&&(x!=t1||y!=c1||!flag)) return;
	flag=false;
	vis[x][y]=false;

	rep(w,1,4)
	{
		reg int xx=x+dx[w],yy=y+dy[w];
//		cout<<xx<<" "<<yy<<endl;
	}
//  cout<<endl;
	rep(w,1,4)
	{
		reg int xx=x+dx[w],yy=y+dy[w];
		dfs(xx,yy);
	}
	return;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	memset(vis,false,sizeof(vis));
	rep(i,1,n)
	{
		string map;
		cin>>map;
		rep(j,1,m)
			if (map[j-1]=='.') vis[i][j]=true;
	}
	cin>>t1>>c1>>t2>>c2;
	dfs(t1,c1);
	cout<<"NO\n";
	return 0;
}
/*
4 6
X...XX
...XX.
.X..X.
......
1 6
2 2

YES

5 4
.X..
...X
X.X.
....
.XX.
5 3
1 1

NO

4 7
..X.XX.
.XX..X.
X...X..
X......
2 2
1 6

YES

3 2
..
X.
.X
3 2
3 1

NO
*/


#include <cstdio>
#define reg register
using namespace std;

int n, m, xa, xb, ya, yb, dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
char a[505][505];
bool vis[505][505], flag;

inline void dfs(int x, int y, int c){
    if(x != xb || y != yb)
        vis[x][y] = 1;
    if(x == xb && y == yb){
        c ++;
        if(c == 1 && a[xb][yb] == 'X'){
            flag = 1;
            return ;
        }
        if(c == 2 && a[xb][yb] == '.'){
            flag = 1;
            return ;
        }
    }
    int nex, ney;
    for(reg int i = 0; i < 4; i++){
        nex = x + dir[i][0];
        ney = y + dir[i][1];
        if(nex < 1 || nex > n || ney < 1 || ney > m || vis[nex][ney])
            continue;
        if(nex != xb || ney != yb)
            if(a[nex][ney] == 'X')
                continue;
        dfs(nex, ney, c);
        if(flag)
            return ;
    }
    vis[x][y] = 0;
}

int main(){
    scanf("%d%d", &n, &m);
    for(reg int i = 1; i <= n; i++){
        scanf("\n");
        for(reg int j = 1; j <= m; j++){
            scanf("%c", &a[i][j]);
        }
    }
    scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
    dfs(xa, ya, 0);
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int n,m,mov[5] = {0,1,-1,0,0},mov1[5] = {0,0,0,1,-1},x1,x2,yy,y2;
char a,mase[505][505];
void dfs(int x,int y){
	if (x == x2 && y == y2 && mase[x][y] == 'X'){
		printf("YES\n");
		exit(0);
	}
	if (mase[x][y] == 'X')
		return ;
	else {
		mase[x][y] = 'X';
		for (int i = 1;i <= 4;i ++){
			int tox = x + mov[i];
			int toy = y + mov1[i];
			if (tox <= 0 || tox > n || toy <= 0 || toy > m)
				continue;
			dfs(tox,toy);
		}
		mase[x][y] = '.';
	}
}
int main(){
	scanf ("%d%d",&n,&m);
	for (int i = 1;i <= n;i ++){
		scanf ("%c",&a);
		for (int j = 1;j <= m;j ++){
			scanf ("%c",&mase[i][j]);
		}
	}
	scanf ("%d%d",&x1,&yy);
	mase[x1][yy] = '.';
	scanf ("%d%d",&x2,&y2);
	dfs(x1,yy);
	printf("NO\n");
}


#include<stdio.h>
#include<string.h>
char c[505][505];
int book[505][505];
int s[4][2]= {{1,0},{-1,0},{0,-1},{0,1}};
struct node
{
    int x,y;
} q[505*505];
int main()
{
    int n,m,sx,sy,tx,ty,flog=0,i;
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++)
    {
        scanf("%s",c[i]);
    }
    scanf("%d %d",&sx,&sy);
    scanf("%d %d",&tx,&ty);
    sx--;
    sy--;
    tx--;
    ty--;
    if(sx==tx&&sy==ty)
    {
        printf("YES\n");
    }
    int tail,head,x,y;
    tail=head=0;
    q[tail].x=sx;
    q[tail].y=sy;
    tail++;
    while(head<tail)
    {
        for(i=0; i<4; i++)
        {
            x=q[head].x+s[i][0];
            y=q[head].y+s[i][1];
            if(x<0||y<0||x>=n||y>=m)
                continue;
            if(c[x][y]=='X'&&x==tx&&y==ty)
            {
                flog=1;
                break;
            }
            else if(c[x][y]=='.')
            {
                q[tail].x=x;
                q[tail].y=y;
                c[x][y]='X';
                tail++;
            }
        }
        head++;
        if(flog==1)
            break;
    }
    if(flog==1)
        printf("YES\n");
    else
        printf("NO\n");;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool judge(int r,int c)
{
    if(pic[r][c] == 'X') return true;
    else
    {
        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(ok(tr,tc) && pic[tr][tc] == '.')
                return true;
        }
    }
}

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
    vis[sr][sc] = 1;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;

        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec)
            {
                if(judge(tr,tc)) return true;
            }
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
                pic[tr][tc] = 'X';
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

int main()
{
 //   freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    puts("NO");
    if(bfs())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool judge(int r,int c)
{
    if(pic[r][c] == 'X') return true;
    else
    {
        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(ok(tr,tc) && pic[tr][tc] == '.')
                return true;
        }
    }
}

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
    vis[sr][sc] = 1;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;
        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec)
            {
                if(judge(er,ec)) return true;
            }
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
                pic[tr][tc] = 'X';
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

int main()
{
 //   freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(bfs())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

//bool dfs(int r,int c)
//{
//    pic[r][c] = 'X';
//    for(int i = 0;i < 4;++i)
//    {
//        int tr = r+dr[i],tc = c+dc[i];
//        if(tr == er && tc == ec)
//        {
//            if(pic[tr][tc] == 'X') return true;
//            else
//            {
//                for(int i = 0;i < 4;++i)
//                {
//                    int ttr = tr+dr[i],ttc = tc+dc[i];
//                    if(ok(ttr,ttc) && pic[ttr][ttc] == '.')
//                        return true;
//                }
//
//            }
//        }
//        else if(ok(tr,tc) && pic[tr][tc] == '.')
//        {
//            if(dfs(tr,tc)) return true;
//            pic[tr][tc] = '.';
//        }
//    }
//    return false;
//}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
    vis[sr][sc] = 1;
    if(sr == er && sc == ec) return true;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;

        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec) return true;
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

bool judge()
{
    if(pic[er][ec] == 'X') return true;
    else
    {
        int cnt = 0;
        for(int i = 0;i < 4;++i)
        {
            int tr = er + dr[i];
            int tc = ec + dc[i];
            if(ok(tr,tc) && pic[tr][tc] == '.')
                cnt++;
        }
        return cnt >= 2;
    }
}

int main()
{
  //  freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(bfs() && judge())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
  //  vis[sr][sc] = 1;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;
        pic[r][c] = 'X';
        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec)
            {
                if(pic[tr][tc] == 'X') return true;
                for(int i = 0;i < 4;++i)
                {
                    int ttr = tr + dr[i],ttc = tc + dc[i];
                    if(ok(ttr,ttc) && pic[ttr][ttc] == '.')
                        return true;
                }
            }
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
          //      pic[tr][tc] = 'X';
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

int main()
{
  //  freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(bfs())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

//bool dfs(int r,int c)
//{
//    pic[r][c] = 'X';
//    for(int i = 0;i < 4;++i)
//    {
//        int tr = r+dr[i],tc = c+dc[i];
//        if(tr == er && tc == ec)
//        {
//            if(pic[tr][tc] == 'X') return true;
//            else
//            {
//                for(int i = 0;i < 4;++i)
//                {
//                    int ttr = tr+dr[i],ttc = tc+dc[i];
//                    if(ok(ttr,ttc) && pic[ttr][ttc] == '.')
//                        return true;
//                }
//
//            }
//        }
//        else if(ok(tr,tc) && pic[tr][tc] == '.')
//        {
//            if(dfs(tr,tc)) return true;
//            pic[tr][tc] = '.';
//        }
//    }
//    return false;
//}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool judge(int r,int c)
{
    if(pic[r][c] == 'X') return true;
    else
    {
        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(ok(tr,tc) && pic[tr][tc] == '.')
                return true;
        }
    }
}

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
    vis[sr][sc] = 1;
  //  if(sr == er && sc == ec) return true;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;

        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec)
            {
                //printf("%d %d\n",r,c);
                if(judge(tr,tc)) return true;
            }
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
                pic[tr][tc] = 'X';
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

int main()
{
 //   freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(bfs())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool judge(int r,int c)
{
    if(pic[r][c] == 'X') return true;
    else
    {
        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(ok(tr,tc) && pic[tr][tc] == '.')
                return true;
        }
    }
}

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
    vis[sr][sc] = 1;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;

        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec)
            {
                if(judge(tr,tc)) return true;
            }
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
                pic[tr][tc] = 'X';
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

int main()
{
 //   freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(bfs())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

//bool dfs(int r,int c)
//{
//    pic[r][c] = 'X';
//    for(int i = 0;i < 4;++i)
//    {
//        int tr = r+dr[i],tc = c+dc[i];
//        if(tr == er && tc == ec)
//        {
//            if(pic[tr][tc] == 'X') return true;
//            else
//            {
//                for(int i = 0;i < 4;++i)
//                {
//                    int ttr = tr+dr[i],ttc = tc+dc[i];
//                    if(ok(ttr,ttc) && pic[ttr][ttc] == '.')
//                        return true;
//                }
//
//            }
//        }
//        else if(ok(tr,tc) && pic[tr][tc] == '.')
//        {
//            if(dfs(tr,tc)) return true;
//            pic[tr][tc] = '.';
//        }
//    }
//    return false;
//}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
    vis[sr][sc] = 1;
  //  if(sr == er && sc == ec) return true;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;

        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec) return true;
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

bool judge()
{
    if(pic[er][ec] == 'X') return true;
    else
    {
        int cnt = 0;
        for(int i = 0;i < 4;++i)
        {
            int tr = er + dr[i];
            int tc = ec + dc[i];
            if(ok(tr,tc) && pic[tr][tc] == '.')
                cnt++;
        }
        return cnt >= 2;
    }
}

int main()
{
  //  freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(bfs() && judge())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

//bool dfs(int r,int c)
//{
//    pic[r][c] = 'X';
//    for(int i = 0;i < 4;++i)
//    {
//        int tr = r+dr[i],tc = c+dc[i];
//        if(tr == er && tc == ec)
//        {
//            if(pic[tr][tc] == 'X') return true;
//            else
//            {
//                for(int i = 0;i < 4;++i)
//                {
//                    int ttr = tr+dr[i],ttc = tc+dc[i];
//                    if(ok(ttr,ttc) && pic[ttr][ttc] == '.')
//                        return true;
//                }
//
//            }
//        }
//        else if(ok(tr,tc) && pic[tr][tc] == '.')
//        {
//            if(dfs(tr,tc)) return true;
//            pic[tr][tc] = '.';
//        }
//    }
//    return false;
//}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool judge(int r,int c)
{
    if(pic[r][c] == 'X') return true;
    else
    {
        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(ok(tr,tc) && pic[tr][tc] == '.')
                return true;
        }
    }
}

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
    vis[sr][sc] = 1;
  //  if(sr == er && sc == ec) return true;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;

        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec)
            {
                if(judge(r,c)) return true;
            }
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
                pic[tr][tc] = 'X';
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

int main()
{
  //  freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(bfs())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

bool dfs(int r,int c)
{
    pic[r][c] = 'X';
    for(int i = 0;i < 4;++i)
    {
        int tr = r+dr[i],tc = c+dc[i];
        if(tr == er && tc == ec)
        {
            if(pic[tr][tc] == 'X') return true;
            else
            {
                for(int i = 0;i < 4;++i)
                {
                    int ttr = tr+dr[i],ttc = tc+dc[i];
                    if(ok(ttr,ttc) && pic[ttr][ttc] == '.')
                        return true;
                }

            }
        }
        else if(ok(tr,tc) && pic[tr][tc] == '.')
        {
            if(dfs(tr,tc)) return true;
            pic[tr][tc] = '.';
        }
    }
    return false;
}

int main()
{
 //   freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(dfs(sr,sc))
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

bool dfs(int r,int c)
{
    if(r == er && c == ec)
    {//puts("OK");
        if(pic[r][c] == 'X') return true;
        else
        {
            for(int i = 0;i < 4;++i)
            {
                int tr = r+dr[i],tc = c+dc[i];
                if(ok(tr,tc) && pic[tr][tc] == '.')
                    return true;
            }
            return false;
        }
    }
 //   if(r == 1 && c == 8) puts("OK");
    pic[r][c] = 'X';
    for(int i = 0;i < 4;++i)
    {
        int tr = r+dr[i],tc = c+dc[i];
        if(tr == er && tc == ec)
        {
            if(pic[tr][tc] == 'X') return true;
            else
            {
                for(int i = 0;i < 4;++i)
                {
                    int ttr = tr+dr[i],ttc = tc+dc[i];
                    if(ok(ttr,ttc) && pic[ttr][ttc] == '.')
                        return true;
                }

            }
        }
        else if(ok(tr,tc) && pic[tr][tc] == '.')
        {
            if(dfs(tr,tc)) return true;
            pic[tr][tc] = '.';
        }
    }
    return false;
}

int main()
{
 //   freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(dfs(sr,sc))
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 500+10;
int R,C;
char pic[maxn][maxn];
bool vis[maxn][maxn];
int sr,sc,er,ec;
const int dr[] = {-1,0,1,0};
const int dc[] = {0,1,0,-1};

bool ok(int r,int c)
{
    return r >= 1 && r <= R && c >= 1 && c <= C;
}

struct Node
{
    int r,c;
    Node(int r = 0,int c = 0):r(r),c(c) {}
};

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<Node> Q;
    Q.push(Node(sr,sc));
  //  vis[sr][sc] = 1;
    while(!Q.empty())
    {
        Node now = Q.front(); Q.pop();
        int r = now.r,c = now.c;
        pic[r][c] = 1;
        for(int i = 0;i < 4;++i)
        {
            int tr = r + dr[i];
            int tc = c + dc[i];
            if(tr == er && tc == ec)
            {
                if(pic[tr][tc] == 'X') return true;
                for(int i = 0;i < 4;++i)
                {
                    int ttr = tr + dr[i],ttc = tc + dc[i];
                    if(ok(ttr,ttc) && pic[ttr][ttc] == '.')
                        return true;
                }
            }
            if(ok(tr,tc) && !vis[tr][tc] && pic[tr][tc] == '.')
            {
                vis[tr][tc] = 1;
          //      pic[tr][tc] = 'X';
                Q.push(Node(tr,tc));
            }
        }
    }
    return false;
}

int main()
{
  //  freopen("./test.txt","r",stdin);
    scanf("%d %d",&R,&C);
    for(int i = 1;i <= R;++i)
        scanf("%s",pic[i]+1);
    scanf("%d %d %d %d",&sr,&sc,&er,&ec);
    if(bfs())
        puts("YES");
    else
        puts("NO");
    return 0;

}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline void dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) puts("YES"), exit(0);
		if (fx < 0 || fx >= m || fy < 0 || fy >= n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		dfs(fx, fy);
	}
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (bx == ex && by == ey) { puts("NO"); return 0; }
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	dfs(bx, by);
	puts("NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline bool dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) return 1;
		if (fx < 0 || fx > m || fy < 0 || fy > n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		if (dfs(fx, fy)) return 1;
	}
	visited[nx][ny] = 0;
	return 0;
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	if (m == 1 && n == 1) { puts("NO"); return 0; }
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	puts(dfs(bx, by) ? "YES" : "NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline void dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) puts("YES"), exit(0);
		if (fx < 0 || fx >= m || fy < 0 || fy >= n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		dfs(fx, fy);
	}
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += (s[fx][fy] == '.' || (fx == bx && fy == by));
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	dfs(bx, by);
	puts("NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline bool dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) return 1;
		if (fx < 0 || fx > m || fy < 0 || fy > n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		if (dfs(fx, fy)) return 1;
	}
	visited[nx][ny] = 0;
	return 0;
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	if (bx == ex && bx == ey) { puts("NO"); return 0; }
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	puts(dfs(bx, by) ? "YES" : "NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline bool dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) return 1;
		if (fx < 0 || fx >= m || fy < 0 || fy >= n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
//		D(fx); D(fy);
		if (dfs(fx, fy)) return 1;
	}
	visited[nx][ny] = 0;
	return 0;
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (bx == ex && bx == ey) { puts("NO"); return 0; }
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	puts(dfs(bx, by) ? "YES" : "NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline void dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) puts("YES"), exit(0);
		if (fx < 0 || fx >= m || fy < 0 || fy >= n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		dfs(fx, fy);
	}
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
//	if (bx == ex && by == ey) { puts("NO"); return 0; }
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	dfs(bx, by);
	puts("NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline void dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) puts("YES"), exit(0);
		if (fx < 0 || fx >= m || fy < 0 || fy >= n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		dfs(fx, fy);
	}
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (bx == ex && bx == ey) { puts("NO"); return 0; }
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	dfs(bx, by);
	puts("NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline void dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) puts("YES"), exit(0);
		if (fx < 0 || fx >= m || fy < 0 || fy >= n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		dfs(fx, fy);
	}
	visited[nx][ny] = 0;
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (bx == ex && bx == ey) { puts("NO"); return 0; }
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	dfs(bx, by);
	puts("NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline bool dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) return 1;
		if (fx < 0 || fx > m || fy < 0 || fy > n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		if (dfs(fx, fy)) return 1;
	}
	visited[nx][ny] = 0;
	return 0;
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (bx == ex && bx == ey) { puts("NO"); return 0; }
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	puts(dfs(bx, by) ? "YES" : "NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline bool dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) return 1;
		if (fx < 0 || fx >= m || fy < 0 || fy >= n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		D(fx); D(fy);
		if (dfs(fx, fy)) return 1;
	}
	visited[nx][ny] = 0;
	return 0;
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (bx == ex && bx == ey) { puts("NO"); return 0; }
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	puts(dfs(bx, by) ? "YES" : "NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


#include<bits/stdc++.h>
#define int ll
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
int m, n, bx, by, ex, ey, visited[505][505];
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
string s[505];
inline bool dfs(int nx, int ny)
{
	visited[nx][ny] = 1;
	for(int i = 0; i < 4; i++)
	{
		int fx = nx+dx[i], fy = ny+dy[i];
		if (fx == ex && fy == ey) return 1;
		if (fx < 0 || fx > m || fy < 0 || fy > n || s[fx][fy] == 'X' || visited[fx][fy]) continue;
		if (dfs(fx, fy)) return 1;
	}
	visited[nx][ny] = 0;
	return 0;
}
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>m>>n;
	for(int i = 0; i < m; i++) cin>>s[i];
	cin>>bx>>by>>ex>>ey;
	bx--; by--; ex--; ey--;
	if (s[ex][ey] == '.')
	{
		int cnt = 0;
		for(int i = 0; i < 4; i++)
		{
			int fx = ex+dx[i], fy = ey+dy[i];
			if (fx < 0 || fx > m || fy < 0 || fy > n) continue;
			cnt += s[fx][fy] == '.';
		}
		if (cnt < 2)
		{
			puts("NO");
			return 0;
		}
	}
	puts(dfs(bx, by) ? "YES" : "NO");
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}


 #include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int n,m,sx,sy,tx,ty;
char mp[505][505];
void dfs(int x,int y)
{
	if(x==tx&y==ty&&mp[x][y]=='X')
	{
		cout<<"YES"<<endl;
		exit(0);
	}
	for(int d=0;d<4;d++)
	{
		int xx=x+dx[d],yy=y+dy[d];
		if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&((xx==tx&&yy==ty)||(mp[xx][yy]=='.')))
		{
			char t=mp[x][y];
			mp[x][y]='X';
			dfs(xx,yy);
			mp[x][y]=t;
		}
	}
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>mp[i][j];
	cin>>sx>>sy>>tx>>ty;
	dfs(sx,sy);
	cout<<"NO"<<endl;
	return 0;
}