Language: C++

#include <cstdio>
#include <queue>
#include <map>
#include <algorithm>
#define Z(n)get<n>(z)
#define M make_pair
#define F first
#define S second
using namespace std;
typedef pair<int,int> pii;
typedef tuple<pii,pii,int> T;
int t[51][51],dx[]={-1,0,1,0},dy[]={0,-1,0,1},a,b,x,y,X,Y,i,j,k;
int main(){
	for(;scanf("%d%d",&a,&b),a;){
		map<pair<pii,pii>,int>m;
		scanf("%d%d%d%d",&x,&y,&X,&Y);x--,y--,X--,Y--;
		for(j=0;j<b;j++)for(i=0;i<a;i++)scanf("%d",t[i]+j);
		queue<T>q;
		m[M(M(x,y),M(X,Y))]=1;
		for(q.push(make_tuple(M(x,y),M(X,Y),0));!q.empty();){
			T z=q.front();q.pop();
			if(Z(0)==Z(1)){printf("%d\n",get<2>(z));goto OK;}
			if(Z(2)<100)for(i=0;i<4;i++){
				pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
				if(!(0<=c1.F&&c1.F<a&&0<=c1.S&&c1.S<b&&!t[c1.F][c1.S]))c1=Z(0),k|=1;
				pii c2=make_pair(Z(1).F+dx[(i+2)%4],Z(1).S+dy[(i+2)%4]);
				if(!(0<=c2.F&&c2.F<a&&0<=c2.S&&c2.S<b&&!t[c2.F][c2.S]))c2=Z(1),k|=2;
				if(k<3&&!m[M(c1,c2)]){
					q.push(make_tuple(c1,c2,Z(2)+1));
					m[M(c1,c2)]=1;
				}
			}
		}
		puts("NA");
		OK:;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:19: error: no matching function for call to 'get<(k = 0)>(T&)'
    5 | #define Z(n)get<n>(z)
      |             ~~~~~~^~~
a.cc:24:50: note: in expansion of macro 'Z'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                  ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/queue:62,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
 1250 |     get(pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
 1255 |     get(pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
 1260 |     get(const pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
 1265 |     get(const pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/deque:81:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
 2445 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2445:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
 2451 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2451:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
 2457 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2457:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
 2466 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2466:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
  138 |     get(array<_Tp, _Nm>&) noexcept;
      |     ^~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note:   template argument deduction/substitution failed:
a.cc:24:53: error: modification of 'k' from outside current evaluation is not a constant expression
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
a.cc:24:53: note: in template argument for type 'long unsigned int'
   24 |                                 pii c1=make_pair(Z(k=0).F+dx[i],Z(0).S+dy[i]);
      |                                                    ~^~
a.cc:5:17: note: in definition of macro 'Z'
    5 | #define Z(n)get<n>(z)
      |                 ^
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& s