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>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef array<int,6> Dice;
int H,W;
int I;
string s[50];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
Dice ds[8];
Dice rot(Dice d,int x){
	if(x==0) return Dice{d[4],d[0],d[2],d[3],d[5],d[1]};
	if(x==1) return Dice{d[3],d[1],d[0],d[5],d[4],d[2]};
	if(x==2) return Dice{d[1],d[5],d[2],d[3],d[0],d[4]};
	if(x==3) return Dice{d[2],d[1],d[5],d[0],d[4],d[3]};
	if(x==4) return Dice{d[0],d[3],d[1],d[4],d[2],d[5]};
	if(x==5) return Dice{d[1],d[2],d[0],d[5],d[3],d[4]};
}
void dfs(Dice d,int x,int y){
	ds[I][d[5]]=s[x][y];
	s[x][y]='.';
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx&&nx<H&&0<=ny&&ny<W&&s[nx][ny]!='.') dfs(rot(d,i),nx,ny);
	}
}
int main(){
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	rep(i,H) rep(j,W) if(s[i][j]!='.'){
		Dice d={0,1,2,3,4,5};
		dfs(d,i,j);
		I++;
	}
	map<char,int> mp;
	rep(i,8){
		int b=0;
		set<char> ss;
		rep(j,6){
			if(ds[i][j]=='#') b++;
			else ss.insert(ds[i][j]),mp[ds[i][j]]++;
		}
		if(b!=3||ss.size()!=3){
			puts("No");
			return 0;
		}
	}
	for(auto p:mp){
		if(p.sc!=4){
			puts("No");
			return 0;
		}
	}
	rep(i,8){
		rep(j,3) if(ds[i][j]=='#'&&ds[i][5-j]=='#'){
			puts("No");
			return 0;
		}
		while(ds[i][0]=='#') ds[i]=rot(ds[i],0);
		int cnt=0;
		while( (ds[i][1]=='#'||ds[i][2]=='#') && cnt<5) ds[i]=rot(ds[i],4),cnt++;
	}
	char c=(*mp.begin()).fs;
	vector<int> as;
	rep(i,8){
		int cnt=0;
		while( ds[i][0]!=c && cnt<5) ds[i]=rot(ds[i],5),cnt++;
		if(cnt<5) as.pb(i);
	}
	assert(as.size()==4);
	char x=ds[as[0]][1];
	vector<char> rs;
	{
		char xc=x;
		int cnt=0,pp=0;
		while(true){
			rep(i,4){
				if(ds[as[i]][1]==x){
					x=ds[as[i]][2];
					rs.pb(x);
					cnt++;
					break;
				}
			}
			if(x==xc) break;
			pp++;
			if(pp==6) break;
		}
		if(cnt!=4||pp==6){
			puts("No");
			return 0;
		}
	}
	for(auto p:mp){
		char cc=p.fs;
		bool ok=1;
		rep(i,4) if(cc==rs[i]) ok=0;
		if(cc==c) ok=0;
		if(ok){
			c=cc;
			break;
		}
	}
	vector<int> bs;
	rep(i,8){
		int cnt=0;
		while( ds[i][0]!=c && cnt<5) ds[i]=rot(ds[i],5),cnt++;
		if(cnt<5) bs.pb(i);
	}
	assert(bs.size()==4);
	x=ds[bs[0]][2];
	vector<char> ss;
	{
		char xc=x;
		int cnt=0;
		int pp=0;
		while(true){
			rep(i,4){
				if(ds[bs[i]][2]==x){
					x=ds[bs[i]][1];
					ss.pb(x);
					cnt++;
					break;
				}
			}
			if(x==xc) break;
			pp++;
			if(pp==6) break;
		}
		if(cnt!=4||pp==6){
			puts("No");
			return 0;
		}
	}
	rep(i,4){
		if(ss==rs){
			puts("Yes");
			return 0;
		}
		ss={ss[3],ss[0],ss[1],ss[2]};
	}
	puts("No");
	return 0;
}