#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct dice{ char a[6]; };
void rot(char &a,char &b,char &c,char &d){ char tmp=a; a=b; b=c; c=d; d=tmp; }
void roll_s(dice &d){ rot(d.a[0],d.a[3],d.a[2],d.a[1]); }
void roll_n(dice &d){ rot(d.a[0],d.a[1],d.a[2],d.a[3]); }
void roll_w(dice &d){ rot(d.a[0],d.a[5],d.a[2],d.a[4]); }
void roll_e(dice &d){ rot(d.a[0],d.a[4],d.a[2],d.a[5]); }

ll h,w;
string bb[33];
string orde;
ll dp[33][33][26][26][7];
ll si=-1,sj=-1;

struct state{
  ll i,j;
  char t,f;
  ll k;
  dice d;
};

int main(){
  while(1){
    cin>>w>>h;
    if(h==0)break;
    rep(i,h){
      cin>>bb[i];
      rep(j,bb[i].size()){
        if(bb[i][j]=='#'){
          si=i; sj=j;
          break;
        }
      }
    }
    cin>>orde;
    rep(i,33)rep(j,33)repl(k,'a','z'+1)repl(l,'a','z'+1)rep(m,7)dp[i][j][k-'a'][l-'a'][m]=INF;
    dice inidice;
    inidice.a[0]='r'; inidice.a[1]='m'; inidice.a[2]='c'; inidice.a[3]='g'; inidice.a[4]='y'; inidice.a[5]='b';
    queue<state> que;
    que.push((state){si,sj,inidice.a[0],inidice.a[1],0,inidice});
    dp[si][sj][inidice.a[0]-'a'][inidice.a[1]-'a'][0]=0;
    while(que.size()){
      state s=que.front(); que.pop();
      if(s.i>0){
        dice nd=s.d;
        roll_n(nd);
        ll ni=s.i-1,nj=s.j;
        if((bb[ni][nj]=='w'||bb[ni][nj]=='#')&&dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k]==INF){
          dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k]=dp[s.i][s.j][s.t-'a'][s.f-'a'][s.k]+1;
          que.push((state){ni,nj,nd.a[0],nd.a[1],s.k,nd});
        }else if(s.k<6&&bb[ni][nj]==orde[s.k]&&bb[ni][nj]==nd.a[0]&&dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k+1]==INF){
          dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k+1]=dp[s.i][s.j][s.t-'a'][s.f-'a'][s.k]+1;
          que.push((state){ni,nj,nd.a[0],nd.a[1],s.k+1,nd});
        }
      }
      if(s.j>0){
        dice nd=s.d;
        roll_w(nd);
        ll ni=s.i,nj=s.j-1;
        if((bb[ni][nj]=='w'||bb[ni][nj]=='#')&&dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k]==INF){
          dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k]=dp[s.i][s.j][s.t-'a'][s.f-'a'][s.k]+1;
          que.push((state){ni,nj,nd.a[0],nd.a[1],s.k,nd});
        }else if(s.k<6&&bb[ni][nj]==orde[s.k]&&bb[ni][nj]==nd.a[0]&&dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k+1]==INF){
          dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k+1]=dp[s.i][s.j][s.t-'a'][s.f-'a'][s.k]+1;
          que.push((state){ni,nj,nd.a[0],nd.a[1],s.k+1,nd});
        }
      }
      if(s.i<h-1){
        dice nd=s.d;
        roll_s(nd);
        ll ni=s.i+1,nj=s.j;
        if((bb[ni][nj]=='w'||bb[ni][nj]=='#')&&dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k]==INF){
          dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k]=dp[s.i][s.j][s.t-'a'][s.f-'a'][s.k]+1;
          que.push((state){ni,nj,nd.a[0],nd.a[1],s.k,nd});
        }else if(s.k<6&&bb[ni][nj]==orde[s.k]&&bb[ni][nj]==nd.a[0]&&dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k+1]==INF){
          dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k+1]=dp[s.i][s.j][s.t-'a'][s.f-'a'][s.k]+1;
          que.push((state){ni,nj,nd.a[0],nd.a[1],s.k+1,nd});
        }
      }
      if(s.j<w-1){
        dice nd=s.d;
        roll_e(nd);
        ll ni=s.i,nj=s.j+1;
        if((bb[ni][nj]=='w'||bb[ni][nj]=='#')&&dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k]==INF){
          dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k]=dp[s.i][s.j][s.t-'a'][s.f-'a'][s.k]+1;
          que.push((state){ni,nj,nd.a[0],nd.a[1],s.k,nd});
        }else if(s.k<6&&bb[ni][nj]==orde[s.k]&&bb[ni][nj]==nd.a[0]&&dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k+1]==INF){
          dp[ni][nj][nd.a[0]-'a'][nd.a[1]-'a'][s.k+1]=dp[s.i][s.j][s.t-'a'][s.f-'a'][s.k]+1;
          que.push((state){ni,nj,nd.a[0],nd.a[1],s.k+1,nd});
        }
      }
    }
    ll res=INF;
    rep(i,33)rep(j,33)repl(k,'a','z'+1)repl(l,'a','z'+1)minch(res,dp[i][j][k-'a'][l-'a'][6]);
    if(res==INF)cout<<"unreachable"<<endl;
    else cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 43460