#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<set>
#include<map>
#include<algorithm>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair

int n,m,b[200],d[200][200];
int target(int t){
	if(t<n){
		t+=n;
		if(b[t]==0)return t;
		if(b[t]==1){
			for(;t+1<2*n&&b[t+1]==1;t++);
			return t;
		}
		for(;t>n&&b[t]==2;t--);
		return t;
	}
	t-=n;
	if(b[t]==0)return t;
	if(b[t]==1){
		for(;t+1<n&&b[t+1]==1;t++);
		return t;
	}
	for(;t>0&&b[t]==2;t--);
	return t;
}
int main(){
	while(cin>>n,n){
		m=2*n;
		rep(i,m)rep(j,m)d[i][j]=i!=j?1<<29:0;
		rep(i,m)cin>>b[i];
		rep(i,m)for(int j=0;j<3&&i%n+j<n;j++)d[i][target(i+j)]=1;
		
		int s=0;
		for(;s+1<n&&b[s]==1&&b[s+1]==1;s++);
		d[0][s]=0;
		for(s=n;s+1<2*n&&b[s]==1&&b[s+1]==1;s++);
		d[n][s]=0;
		
		rep(k,m)rep(i,m)rep(j,m)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		int ans=min(min(d[0][n-1],d[0][2*n-1]),min(d[n][n-1],d[n][2*n-1]));
		if(ans==1<<29)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}