#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "<0)CHMIN(dist[i][j], dist[i-1][j]+c); if(j>0)CHMIN(dist[i][j], dist[i][j-1]+c); } pass[h-1][w-1] = true; FORR(i,0,h)FORR(j,0,w)if(i!=h-1 || j!=w-1){ if(i0 ? (1<<(x-1)) : 0); REP(msk,1< 0 && pass[y][x]; int nmsk = (msk & del) ^ (nbit << x); dp[1][nmsk] = (dp[1][nmsk] + dp[0][msk]) % MOD; } if(mp[y][x]=='?'){ REP(msk,1<>(w-1))&1){ ans = (ans + dp[0][i]) % MOD; } printf("%lld\n%lld\n",dist[h-1][w-1],ans); return 0; }