#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

string ans = "xxoxxxabcxdefghxijkxxxoxx";

class board{
public:
  int h,c;
  string s;
  board(int x,int y,string z){ h=x; c=y; s=z;}
  const bool operator<(const board x)const{return h+c>x.h+x.c; }
};

int score(string s){
  int res=0,m;
  for(int i=0;i<25;i++){
    if(s[i]!='x' && s[i]!='o'){
      for(int j=0;j<25;j++){
	if(s[i]==ans[j]){
	  m = abs(i/5-j/5) + abs(i%5-j%5);
	  break;
	}
      }
      res += m;
    }
  }
  return res;
}

char trans(int x){
  if(!x)return 'o';
  else return 'a'+x-1;
}

int main(){
  string s = "xxxxxxxxxxxxxxxxxxxxxxxxx";
  int tmp,cost;

  for(;;){
    cin >> tmp;
    if(tmp<0)break;

    s[2] = trans(tmp);
    for(int i=0;i<3;i++){
      cin >> tmp;
      s[6+i] = trans(tmp);
    }
    for(int i=0;i<5;i++){
      cin >> tmp;
      s[10+i] = trans(tmp);
    }
    for(int i=0;i<3;i++){
      cin >> tmp;
      s[16+i] = trans(tmp);
    }
    cin >> tmp;
    s[22] = trans(tmp);

    priority_queue<board> q;
    q.push(board(score(s),0,s));

    //map<string,bool> m;
    //m[s] = true;
    while(q.size()){
      board p = q.top();q.pop();
      int dx[] = {-5,1,5,-1};

      cost = p.c;
      if(p.s == ans)break;
      if(p.h+cost>20){
	cost = 21;
	break;
      }

      //m[p.s] = true;
      for(int i=0;i<25;i++){
	if(p.s[i]=='o'){
	  for(int j=0;j<4;j++){
	    int sx = i + dx[j];
	    string str = p.s;
	    if(sx<0 || 25<=sx)continue;
	    if(str[sx] == 'x' || str[sx] == 'o')continue;
	    swap(str[i],str[sx]);
	    /*if(!m[str])*/q.push(board(score(str),cost+1,str));
	  }
	}
      }
    }

    if(cost>20)cout << "NA\n";
    else cout << cost << endl;
  }
}