#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


const int MOD = 100000;
void add(int &a, int b) { a += b; if (a >= MOD) a -= MOD; }

int n, m;
string fi[25];

int now[1<<20][2], next[1<<20][2];
char base[3] = {'J', 'O', 'I'};

int main() {
	while (cin >> n >> m) { 
		for (int i = 0; i < n; ++i) cin >> fi[i];
		
		memset(now, 0, sizeof(now));
		now[0][0] = 1;

		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				memset(next, 0, sizeof(next));
				for (int bit = 0; bit < (1<<(m-1)); ++bit) {
					for (int k = 0; k < 3; ++k) {
						char c = base[k];

						if (fi[i][j] != '?' && fi[i][j] != c) continue;
						if (j != m-1) {
							if (c == 'J') {
								int nbit = bit | (1<<j);
								nbit &= ~(1<<(j-1));

								add(next[nbit][0], now[bit][0]);
								add(next[nbit][1], now[bit][1]);
							}
							if (c == 'O') {
								int nbit = bit & ~(1<<j);
								if ( bit & (1<<(j-1)) ) nbit |= 1<<(j-1);
								else nbit &= ~(1<<(j-1));

								add(next[nbit][0], now[bit][0]);
								add(next[nbit][1], now[bit][1]);
							}
							if (c == 'I') {
								int nbit = bit & ~(1<<(j-1)) & ~(1<<j);
								if (bit & (1<<j)) {
									add(next[nbit][1], now[bit][0]);
									add(next[nbit][1], now[bit][1]);
								}
								else {
									add(next[nbit][0], now[bit][0]);
									add(next[nbit][1], now[bit][1]);
								}
							}
						}
						else {
							if (c == 'J') {
								int nbit = bit;
								nbit &= ~(1<<(j-1));

								add(next[nbit][0], now[bit][0]);
								add(next[nbit][1], now[bit][1]);
							}
							if (c == 'O') {
								int nbit = bit;
								if ( bit & (1<<(j-1)) ) nbit |= 1<<(j-1);
								else nbit &= ~(1<<(j-1));

								add(next[nbit][0], now[bit][0]);
								add(next[nbit][1], now[bit][1]);
							}
							if (c == 'I') {
								int nbit = bit & ~(1<<(j-1));
								if (bit & (1<<j)) {
									add(next[nbit][1], now[bit][0]);
									add(next[nbit][1], now[bit][1]);
								}
								else {
									add(next[nbit][0], now[bit][0]);
									add(next[nbit][1], now[bit][1]);
								}
							}
						}
					}
				}

				for (int bit = 0; bit < (1<<(m-1)); ++bit) {
					now[bit][0] = next[bit][0];
					now[bit][1] = next[bit][1];
				}
			}
		}

		int res = 0;
		for (int bit = 0; bit < (1<<(m-1)); ++bit) {
			add(res, now[bit][1]);
		}

		cout << res << endl;
	}
    return 0;
}


Measured memory_bytes: 17604