import std.stdio;
import std.algorithm;
import std.math;
import core.stdc.stdio;
import core.memory;

//?????¨?????§???????????????????????????????????§?????????????????????J??§??????????????????JO???????????????*(w-1)
int[] now,next;

static immutable int modBase = 100000;

void main(){
	GC.disable;
	
	char[21][20] mapData;
	int w,h;
	scanf("%d%d",&h,&w);
	
	now = new int[1<<(w+1)];
	next = new int[1<<(w+1)];
	
	for(int i=0;i<h;i++)
		scanf("%s",mapData[i].ptr);
	now[] = 0;
	now[0] = 1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			next[] = 0;
			for(int k=0;k<(1<<(w+1));k++){
				//J?????????
				if(mapData[i][j] == 'J' || mapData[i][j] == '?'){
					int idx;
					if(j == 0){
						idx = (1<<(w-1))|(k&(~(1)));
					}else{
						idx = (1<<(w-1))|(k&(~(3<<(j-1))));
					}
					next[idx] += now[k];
					next[idx] %= modBase;
				//	writeln(k," J ",idx," ",now[k]," ",next[idx]);
				}
				//O?????????
				if(mapData[i][j] == 'O' || mapData[i][j] == '?'){
					int idx;
					if(j == 0){
						idx = (~(1<<(w-1)))&k&(~1);
					}else if(k&(1<<(w-1))){
						idx = (~(1<<(w-1)))&k&(~(1<<j))|(1<<(j-1));
					}else{
						idx = (~(1<<(w-1)))&k&(~(3<<(j-1)));
					}
					next[idx] += now[k];
					next[idx] %= modBase;
				//	writeln(k," O ",idx," ",now[k]," ",next[idx]);
				}
				//I?????????
				if(mapData[i][j] == 'I' || mapData[i][j] == '?'){
					int idx=0;
					if(j < w-1 &&k & (1<<j)){
						idx = (1<<w);
					}
					if(j==0){
						idx = idx|((~(1<<(w-1)))&k&(~1));
					}else{
						idx = idx|((~(1<<(w-1)))&k&(~(3<<(j-1))));
					}
					next[idx] += now[k];
					next[idx] %= modBase;
				//	writeln(k," I ",idx," ",now[k]," ",next[idx]);
				}
			}
			swap(now,next);
		}
	}
	int ans=0;
	for(int i=(1<<w);i<(1<<(w+1));i++){
		ans = (ans+now[i])%modBase;
	}
	printf("%d\n",ans);
}