#include<iostream>
#include<cstdio>
using namespace std;
int field[5][5];
int log[5][5];
int num[13];
void SETING();
int main(){
  while(cin >>num[0]){
    if(num[0] == -1){break;}
    int a;
    for(int i=1; i<13; i++){
      cin >>a;
      num[i] = a;
    }
    SETING();
    int cost = 0;
    for(int k=1; k<12; k++){
      int x,y,s,t;
      for(int i=0; i<5; i++){
	for(int j=0; j<5; j++){
	  if(field[i][j] == k){x = i; y = j;}
	}
      }
      for(int i=0; i<5; i++){
	for(int j=0; j<5; j++){
	  if(log[i][j] == k){s = i; t = j;}
	}
      }
      if(x>s){cost+=x-s;}
      if(x<s){cost+=s-x;}
      if(y>t){cost+=y-t;}
      if(y<t){cost+=t-y;}
    }
    if(cost<21){cout <<cost<<endl;}
    else{cout <<"NA"<<endl;}
  }
  return 0;
}
void SETING(){
  for(int i=0; i<5; i++){
    for(int j=0; j<5; j++){
      field[i][j] = -1;
      log[i][j] = -1;
    }
  }
  field[2][0] = num[0];
  field[1][1] = num[1];
  field[2][1] = num[2];
  field[3][1] = num[3];
  field[1][2] = num[4];
  field[1][2] = num[5];
  field[2][2] = num[6];
  field[3][2] = num[7];
  field[4][2] = num[8];
  field[1][3] = num[9];
  field[2][3] = num[10];
  field[3][3] = num[11];
  field[2][4] = num[12];
  log[2][0] = 0;
  log[1][1] = 1;
  log[2][1] = 2;
  log[3][1] = 3;
  log[1][2] = 4;
  log[1][2] = 5;
  log[2][2] = 6;
  log[3][2] = 7;
  log[4][2] = 8;
  log[1][3] = 9;
  log[2][3] = 10;
  log[3][3] = 11;
  log[2][4] = 0;
}