Problem: Mary Thomas has a number of sheets of squared paper. Some of squares are painted either in black or some colorful color (such as red and blue) on the front side. Cutting off the unpainted part, she will have eight opened-up unit cubes. A unit cube here refers to a cube of which each face consists of one square.

She is going to build those eight unit cubes with the front side exposed and then a bicube with them. A bicube is a cube of the size 2 × 2 × 2, consisting of eight unit cubes, that satisfies the following conditions:

* faces of the unit cubes that comes to the inside of the bicube are all black;
* each face of the bicube has a uniform colorful color; and
* the faces of the bicube have colors all different.



Your task is to write a program that reads the specification of a sheet of squared paper and decides whether a bicube can be built with the eight unit cubes resulting from it.



Input

The input contains the specification of a sheet. The first line contains two integers H and W, which denote the height and width of the sheet (3 ≤ H, W ≤ 50). Then H lines follow, each consisting of W characters. These lines show the squares on the front side of the sheet. A character represents the color of a grid: alphabets and digits ('A' to 'Z', 'a' to 'z', '0' to '9') for colorful squares, a hash ('#') for a black square, and a dot ('.') for an unpainted square. Each alphabet or digit denotes a unique color: squares have the same color if and only if they are represented by the same character.

Each component of connected squares forms one opened-up cube. Squares are regarded as connected when they have a common edge; those just with a common vertex are not.

Output

Print "Yes" if a bicube can be built with the given sheet; "No" otherwise.

Examples

Input

3 40
.a....a....a....a....f....f....f....f...
#bc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.
.#....#....#....#....#....#....#....#...


Output

Yes


Input

3 40
.a....a....a....a....f....f....f....f...
bc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.
.#....#....#....#....#....#....#....#...


Output

Yes


Input

5 35
.a....a....a....a....f....f....f...
bc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.
.#..f.#....#....#....#....#....#...
..e##..............................
.b#................................


Output

Yes


Input

3 40
.a....a....a....a....f....f....f....f...
bc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.
.#....#....#....#....#....#....#....#...


Output

No

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Dice{
  int s[6];
  void roll(char c){
    //the view from above
    // N
    //W E
    // S
    //s[0]:top
    //s[1]:south
    //s[2]:east
    //s[3]:west
    //s[4]:north
    //s[5]:bottom
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    
    // migi neji 
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }
    
    if(c=='L'){
      b=s[1];
      s[1]=s[3];
      s[3]=s[4];
      s[4]=s[2];
      s[2]=b;
    }
    
  }
  int top() {
    return s[0];
  }
  int hash(){
    int res=0;
    for(int i=0;i<6;i++) res=res*256+s[i];
    return res;
  }
};
vector<Dice> makeDices(Dice d){
  vector<Dice> res;
  for(int i=0;i<6;i++){
    Dice t(d);
    if(i==1) t.roll('N'); 
    if(i==2) t.roll('S'); 
    if(i==3) t.roll('S'),t.roll('S');
    if(i==4) t.roll('L'); 
    if(i==5) t.roll('R'); 
    for(int k=0;k<4;k++){
      res.push_back(t);
      t.roll('E');
    }
  }
  return res;
}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, int> dict(const vector<T> &v){
  map<T, int> res;
  for(int i=0;i<(int)v.size();i++)
    res[v[i]]=i;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++) cin>>s[i];

  int dy[]={-1,0,1,0,0};
  int dx[]={0,1,0,-1,0};

  int dd[6][4]={{4,2,1,3},
                {0,2,5,3},
                {4,5,1,0},
                {4,0,1,5},
                {5,2,0,3},
                {1,2,4,3}};
  
  struct T{
    int y,x,v,p;
    T(){}
    T(int y,int x,int v,int p):y(y),x(x),v(v),p(p){}    
  };
  
  auto in=[&](int y,int x){return 0<=y&&y<h&&0<=x&&x<w;};

  vector<vector<int> > used(h,vector<int>(w,-1));
  vector<vector<int> > dc;
  auto bfs=
    [&](int sy,int sx)->void{
      queue<T> q;
      used[sy][sx]=0;
      q.emplace(sy,sx,0,4);
      vector<int> vs(6,'#');
      while(!q.empty()){
        T t=q.front();q.pop();
        vs[t.v]=int(s[t.y][t.x]);
        
        int pd=0,pv=used[t.y-dy[t.p]][t.x-dx[t.p]];
        for(int k=0;k<4;k++)
          if(dd[t.v][k]==pv) pd=(6-t.p)+(k);

        pd%=4;
        //cout<<t.v<<":"<<t.p<<":"<<char(vs[t.v])<<":"<<pv<<" "<<pd<<endl;
          
        for(int k=0;k<4;k++){
          int ny=t.y+dy[k],nx=t.x+dx[k];
          if(!in(ny,nx)||s[ny][nx]=='.'||~used[ny][nx]) continue;
          used[ny][nx]=dd[t.v][(pd+k)%4];
          q.emplace(ny,nx,used[ny][nx],k);
        }
      }      
      Dice di;
      for(int i=0;i<6;i++) di.s[i]=vs[i];
      auto ds=makeDices(di);
      for(Dice d:ds){
        if(d.s[0]=='#'||d.s[1]=='#'||d.s[2]=='#') continue;
        dc.push_back(vector<int>({d.s[0],d.s[1],d.s[2]}));
        // cout<<char(d.s[0])<<" "<<char(d.s[1])<<" "<<char(d.s[2])<<endl;
      }
    };
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(~used[i][j]||s[i][j]=='.') continue;
      bfs(i,j);
    }    
  }
  
  dc=compress(dc);
  int m=dc.size();

  using D = tuple<int, int, int>;
  set<D> ss;
  for(int i=0;i<m;i++)
    ss.emplace(dc[i][0],dc[i][1],dc[i][2]);

  auto YES=[&](){cout<<"Yes"<<endl;exit(0);};

  for(int i=0;i<m;i++){
    for(int j=0;j<i;j++){
      int a=dc[i][0],b=dc[i][1],c=dc[i][2];
      int d=dc[j][0],e=dc[j][1],f=dc[j][2];
      set<int> sc({a,b,c,d,e,f});
      if(sc.size()!=6u) continue;
      
      //cout<<char(a)<<" "<<char(b)<<" "<<char(c);
      //cout<<" "<<char(d)<<" "<<char(e)<<" "<<char(f)<<endl;
      
      if(!ss.count(D(d,b,e))) continue;   
      if(!ss.count(D(e,b,a))) continue; 
      if(!ss.count(D(a,b,c))) continue;
      if(!ss.count(D(c,b,d))) continue;  

      if(!ss.count(D(d,e,f))) continue;
      if(!ss.count(D(e,a,f))) continue;
      if(!ss.count(D(a,c,f))) continue;
      if(!ss.count(D(c,d,f))) continue;

      YES();
    }
  }
      
  
  cout<<"No"<<endl;
  return 0;
}