/*

VJEKOSLAV GIACOMETTI

XV. GIMNAZIJA

CONTEST #4

JUNIOR DIVISION

CODE 7076

*/

 

#include <iostream>

#include <deque>

#include <vector>

#define MX 1000

 

using namespace std;

 

struct gr {

       int brs, s[8];

};

 

struct zapis {

       vector <int>bio;

       int tr;

};

 

vector <gr>graf;

deque <zapis>q;

int g[MX][MX];

int rd, st;

 

int nadji(int brc) {

    int i, j;

    brc++;

    for (i=0;i<MX;++i) {

        for (j=0;j<MX;++j) {

            if (g[i][j] == brc) {

               rd = i;

               st = j;

               break;

            }

        }

    }

}

 

int main(void) {

    int a, b, cv = 0, i, j, pa, pb, ka, kb, k, pc, kc;

    gr tmp;

    zapis tmp1, tmp2;

    bool ne, kraj;

 

    for (i=0;i<MX;++i) {

        for (j=0;j<MX;++j) {   

            g[i][j] = 0;

        }

    }

   

    while (true) {

                        cin >> a >> b;

                        if ((a == 0) && (b == 0)) break;

                        cv++;

                        g[a][b] = cv;

            }

           

            for (k=1;k<=cv;++k) {

    for (i=0;i<MX;++i) {

        for (j=0;j<MX;++j) {

            if (g[i][j] != k) continue;

            tmp.brs = 0;

            if (g[i][j] > 0) {

               if (g[i-1][j] > 0) {

                  tmp.brs++;

                  tmp.s[tmp.brs] = g[i-1][j] - 1;

               }

               if (g[i-1][j+1] > 0) {

                  tmp.brs++;

                  tmp.s[tmp.brs] = g[i-1][j+1] - 1;

               }

               if (g[i][j+1] > 0) {

                  tmp.brs++;

                  tmp.s[tmp.brs] = g[i][j+1] - 1;

               }

               if (g[i+1][j+1] > 0) {

                  tmp.brs++;

                  tmp.s[tmp.brs] = g[i+1][j+1] - 1;

               }

               if (g[i+1][j] > 0) {

                  tmp.brs++;

                  tmp.s[tmp.brs] = g[i+1][j] - 1;

               }

               if (g[i+1][j-1] > 0) {

                  tmp.brs++;

                  tmp.s[tmp.brs] = g[i+1][j-1] - 1;

               }

               if (g[i][j-1] > 0) {

                  tmp.brs++;

                  tmp.s[tmp.brs] = g[i][j-1] - 1;

               }

               if (g[i-1][j-1] > 0) {

                  tmp.brs++;

                  tmp.s[tmp.brs] = g[i-1][j-1] - 1;

               }

            }

            graf.push_back(tmp);

        }

    }

    }

           

            for (i=0;i<5;++i) {

        cin >> pa >> pb >> ka >> kb;

        pc = g[pa][pb] - 1;

        kc = g[ka][kb] - 1;

        tmp1.tr = pc;

        tmp1.bio.clear();

        q.clear();

        q.push_front(tmp1);

        kraj = false;

        while (!q.empty()) {

              tmp2 = q.back();

              if (q.size() > 40000) {

                 cout << "NONE" << endl;

                 kraj = true;

                 break;

              }

              if (kraj) break;

              q.pop_back();

              if (tmp2.tr == kc) {

                 for (j=0;j<tmp2.bio.size();++j) {

                     nadji(tmp2.bio[j]);

                     cout << rd << " " << st << " ";

                 }

                 nadji(tmp2.tr);

                 cout << rd << " " << st << " " << endl;

                 kraj = true;

                 break;

              }

              if (kraj) break;

              for (j=1;j<=graf[tmp2.tr].brs;++j) {

                  ne = false;

                  for (k=0;k<tmp2.bio.size();++k) {

                      if (tmp2.bio[k] == graf[tmp2.tr].s[j]) {

                         ne = true;

                         break;

                      }

                  }

                  tmp1.tr = graf[tmp2.tr].s[j];

                  tmp1.bio = tmp2.bio;

                  tmp1.bio.push_back(tmp2.tr);

                  q.push_front(tmp1);

              }

              if (q.empty()) cout << "NONE" << endl;

        }

    }

 

            return 0;

}