#include <bits/stdc++.h> using namespace std; typedef long long ll; //Autor: Michał Szeliga #ifdef LOCAL #define debug(...) __VA_ARGS__; #else #define debug(...) {} #endif //PREPROCESSING ll pre[9][9][9][2]; // ll n =7; ll m = 6; ll wy; ll odw = 0; ll dwu[101][101]; ll policznewton(ll n, ll k){ __int128 wy = 1; if (!n || !k) return 1; for (ll i = max(k,n-k)+1; i <= n; i++) wy *= i; for (ll i = 1; i <= min(k,n-k); i++) wy /= i; return wy; } ll dwumian(ll n, ll k){ return dwu[n][k]; } void policz(vector<pair<ll,ll> > pozycje, int ilepionkow, int ilebialych){ if ((ll)pozycje.size() == ilebialych){ //cerr<<odw<<"\n"; ll ilenpar = ilepionkow-ilebialych; odw++; bool tab[n][m]; ll delta[n][m]; for (ll i = 0; i < n; i++){ for (ll j = 0; j < m; j++){ delta[i][j] = 4; if (!i) delta[i][j]--; if (!j) delta[i][j]--; if (i == n-1) delta[i][j]--; if (j == m-1) delta[i][j]--; tab[i][j] = 0; } } //cout<<"DLA CIĄGU: \n"; for (auto j : pozycje){ tab[j.first][j.second] = 1; //cout<<j.first<<" "<<j.second<<" # "; } //cout<<" wynikiem jest "; ll deg = 0; vector<ll> val; for (ll i = 0; i < n; i++){ for (ll j = 0; j < m; j++){ if (tab[i][j] == 0) continue; if (i){ deg++; delta[i-1][j] -= 2; } if (j){ deg++; delta[i][j-1] -= 2; } if (i < n-1){ deg++; delta[i+1][j] -= 2; } if (j < m-1){ deg++; delta[i][j+1] -= 2; } } } for (ll i = 0; i < n; i++) for (ll j = 0; j < m; j++) if (!tab[i][j] && (i+j)%2) val.push_back(delta[i][j]); ll DL = val.size(); wy += deg*dwumian(DL, ilenpar); //cout<<"\n"; for (ll i = 0; i < DL; i++){ //cout<<val[i]<<" "; for (ll j = 0; j < ilenpar; j++){ if (i < j || DL-i-1 < ilenpar-j-1) continue; //cout<<i<<" "<<val[i]<<" # "<<j<<" ### "<<val[i]*dwumian(i,j)*dwumian(DL-i-1,ilenpar-j-1)<<"\n"; wy += val[i]*dwumian(i,j)*dwumian(DL-i-1,ilenpar-j-1); } } // cout<<wy[ilebialych][ilenpar]-xd<<"\n"; //exit(0); //cout<<"DLA PIONKÓW deg = "<<deg<<"\n"; /*for (auto j : pozycje){ cout<<j.first<<" "<<j.second<<" # "; } cout<<"\n";*/ return; } ll x = 0; ll y = -1; if (pozycje.size()){ x = pozycje.back().first; y = pozycje.back().second; } for (ll i = x; i < n; i++){ for (ll j = i%2; j < m; j += 2){ if (i == x && j <= y) continue; pozycje.push_back({i,j}); policz(pozycje,ilepionkow,ilebialych); pozycje.pop_back(); } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); debug(freopen("wietest/in/125.in","r",stdin);); //PREPROCESSING pre[1][2][1][0]=1; pre[1][2][1][1]=1; pre[1][3][1][0]=2; pre[1][3][1][1]=2; pre[1][3][2][0]=2; pre[1][3][2][1]=2; pre[1][4][1][0]=3; pre[1][4][1][1]=3; pre[1][4][2][0]=6; pre[1][4][2][1]=6; pre[1][4][3][0]=3; pre[1][4][3][1]=3; pre[1][5][1][0]=4; pre[1][5][1][1]=4; pre[1][5][2][0]=12; pre[1][5][2][1]=12; pre[1][5][3][0]=12; pre[1][5][3][1]=12; pre[1][5][4][0]=4; pre[1][5][4][1]=4; pre[1][6][1][0]=5; pre[1][6][1][1]=5; pre[1][6][2][0]=20; pre[1][6][2][1]=20; pre[1][6][3][0]=30; pre[1][6][3][1]=30; pre[1][6][4][0]=20; pre[1][6][4][1]=20; pre[1][6][5][0]=5; pre[1][6][5][1]=5; pre[1][7][1][0]=6; pre[1][7][1][1]=6; pre[1][7][2][0]=30; pre[1][7][2][1]=30; pre[1][7][3][0]=60; pre[1][7][3][1]=60; pre[1][7][4][0]=60; pre[1][7][4][1]=60; pre[1][7][5][0]=30; pre[1][7][5][1]=30; pre[1][7][6][0]=6; pre[1][7][6][1]=6; pre[1][8][1][0]=7; pre[1][8][1][1]=7; pre[1][8][2][0]=42; pre[1][8][2][1]=42; pre[1][8][3][0]=105; pre[1][8][3][1]=105; pre[1][8][4][0]=140; pre[1][8][4][1]=140; pre[1][8][5][0]=105; pre[1][8][5][1]=105; pre[1][8][6][0]=42; pre[1][8][6][1]=42; pre[1][8][7][0]=7; pre[1][8][7][1]=7; pre[2][1][1][0]=1; pre[2][1][1][1]=1; pre[2][2][1][0]=4; pre[2][2][1][1]=4; pre[2][2][2][0]=8; pre[2][2][2][1]=8; pre[2][2][3][0]=4; pre[2][2][3][1]=4; pre[2][3][1][0]=7; pre[2][3][1][1]=7; pre[2][3][2][0]=28; pre[2][3][2][1]=28; pre[2][3][3][0]=42; pre[2][3][3][1]=42; pre[2][3][4][0]=28; pre[2][3][4][1]=28; pre[2][3][5][0]=7; pre[2][3][5][1]=7; pre[2][4][1][0]=10; pre[2][4][1][1]=10; pre[2][4][2][0]=60; pre[2][4][2][1]=60; pre[2][4][3][0]=150; pre[2][4][3][1]=150; pre[2][4][4][0]=200; pre[2][4][4][1]=200; pre[2][4][5][0]=150; pre[2][4][5][1]=150; pre[2][4][6][0]=60; pre[2][4][6][1]=60; pre[2][4][7][0]=10; pre[2][4][7][1]=10; pre[2][5][1][0]=13; pre[2][5][1][1]=13; pre[2][5][2][0]=104; pre[2][5][2][1]=104; pre[2][5][3][0]=364; pre[2][5][3][1]=364; pre[2][5][4][0]=728; pre[2][5][4][1]=728; pre[2][5][5][0]=910; pre[2][5][5][1]=910; pre[2][5][6][0]=728; pre[2][5][6][1]=728; pre[2][5][7][0]=364; pre[2][5][7][1]=364; pre[2][5][8][0]=104; pre[2][5][8][1]=104; pre[2][6][1][0]=16; pre[2][6][1][1]=16; pre[2][6][2][0]=160; pre[2][6][2][1]=160; pre[2][6][3][0]=720; pre[2][6][3][1]=720; pre[2][6][4][0]=1920; pre[2][6][4][1]=1920; pre[2][6][5][0]=3360; pre[2][6][5][1]=3360; pre[2][6][6][0]=4032; pre[2][6][6][1]=4032; pre[2][6][7][0]=3360; pre[2][6][7][1]=3360; pre[2][6][8][0]=1920; pre[2][6][8][1]=1920; pre[2][7][1][0]=19; pre[2][7][1][1]=19; pre[2][7][2][0]=228; pre[2][7][2][1]=228; pre[2][7][3][0]=1254; pre[2][7][3][1]=1254; pre[2][7][4][0]=4180; pre[2][7][4][1]=4180; pre[2][7][5][0]=9405; pre[2][7][5][1]=9405; pre[2][7][6][0]=15048; pre[2][7][6][1]=15048; pre[2][7][7][0]=17556; pre[2][7][7][1]=17556; pre[2][7][8][0]=15048; pre[2][7][8][1]=15048; pre[2][8][1][0]=22; pre[2][8][1][1]=22; pre[2][8][2][0]=308; pre[2][8][2][1]=308; pre[2][8][3][0]=2002; pre[2][8][3][1]=2002; pre[2][8][4][0]=8008; pre[2][8][4][1]=8008; pre[2][8][5][0]=22022; pre[2][8][5][1]=22022; pre[2][8][6][0]=44044; pre[2][8][6][1]=44044; pre[2][8][7][0]=66066; pre[2][8][7][1]=66066; pre[2][8][8][0]=75504; pre[2][8][8][1]=75504; pre[3][1][1][0]=2; pre[3][1][1][1]=2; pre[3][1][2][0]=2; pre[3][1][2][1]=2; pre[3][2][1][0]=7; pre[3][2][1][1]=7; pre[3][2][2][0]=28; pre[3][2][2][1]=28; pre[3][2][3][0]=42; pre[3][2][3][1]=42; pre[3][2][4][0]=28; pre[3][2][4][1]=28; pre[3][2][5][0]=7; pre[3][2][5][1]=7; pre[3][3][1][0]=12; pre[3][3][1][1]=12; pre[3][3][2][0]=84; pre[3][3][2][1]=84; pre[3][3][3][0]=252; pre[3][3][3][1]=252; pre[3][3][4][0]=420; pre[3][3][4][1]=420; pre[3][3][5][0]=420; pre[3][3][5][1]=420; pre[3][3][6][0]=252; pre[3][3][6][1]=252; pre[3][3][7][0]=84; pre[3][3][7][1]=84; pre[3][3][8][0]=12; pre[3][3][8][1]=12; pre[3][4][1][0]=17; pre[3][4][1][1]=17; pre[3][4][2][0]=170; pre[3][4][2][1]=170; pre[3][4][3][0]=765; pre[3][4][3][1]=765; pre[3][4][4][0]=2040; pre[3][4][4][1]=2040; pre[3][4][5][0]=3570; pre[3][4][5][1]=3570; pre[3][4][6][0]=4284; pre[3][4][6][1]=4284; pre[3][4][7][0]=3570; pre[3][4][7][1]=3570; pre[3][4][8][0]=2040; pre[3][4][8][1]=2040; pre[3][5][1][0]=22; pre[3][5][1][1]=22; pre[3][5][2][0]=286; pre[3][5][2][1]=286; pre[3][5][3][0]=1716; pre[3][5][3][1]=1716; pre[3][5][4][0]=6292; pre[3][5][4][1]=6292; pre[3][5][5][0]=15730; pre[3][5][5][1]=15730; pre[3][5][6][0]=28314; pre[3][5][6][1]=28314; pre[3][5][7][0]=37752; pre[3][5][7][1]=37752; pre[3][5][8][0]=37752; pre[3][5][8][1]=37752; pre[3][6][1][0]=27; pre[3][6][1][1]=27; pre[3][6][2][0]=432; pre[3][6][2][1]=432; pre[3][6][3][0]=3240; pre[3][6][3][1]=3240; pre[3][6][4][0]=15120; pre[3][6][4][1]=15120; pre[3][6][5][0]=49140; pre[3][6][5][1]=49140; pre[3][6][6][0]=117936; pre[3][6][6][1]=117936; pre[3][6][7][0]=216216; pre[3][6][7][1]=216216; pre[3][6][8][0]=308880; pre[3][6][8][1]=308880; pre[3][7][1][0]=32; pre[3][7][1][1]=32; pre[3][7][2][0]=608; pre[3][7][2][1]=608; pre[3][7][3][0]=5472; pre[3][7][3][1]=5472; pre[3][7][4][0]=31008; pre[3][7][4][1]=31008; pre[3][7][5][0]=124032; pre[3][7][5][1]=124032; pre[3][7][6][0]=372096; pre[3][7][6][1]=372096; pre[3][7][7][0]=868224; pre[3][7][7][1]=868224; pre[3][7][8][0]=1612416; pre[3][7][8][1]=1612416; pre[3][8][1][0]=37; pre[3][8][1][1]=37; pre[3][8][2][0]=814; pre[3][8][2][1]=814; pre[3][8][3][0]=8547; pre[3][8][3][1]=8547; pre[3][8][4][0]=56980; pre[3][8][4][1]=56980; pre[3][8][5][0]=270655; pre[3][8][5][1]=270655; pre[3][8][6][0]=974358; pre[3][8][6][1]=974358; pre[3][8][7][0]=2760681; pre[3][8][7][1]=2760681; pre[3][8][8][0]=6310128; pre[3][8][8][1]=6310128; pre[4][1][1][0]=3; pre[4][1][1][1]=3; pre[4][1][2][0]=6; pre[4][1][2][1]=6; pre[4][1][3][0]=3; pre[4][1][3][1]=3; pre[4][2][1][0]=10; pre[4][2][1][1]=10; pre[4][2][2][0]=60; pre[4][2][2][1]=60; pre[4][2][3][0]=150; pre[4][2][3][1]=150; pre[4][2][4][0]=200; pre[4][2][4][1]=200; pre[4][2][5][0]=150; pre[4][2][5][1]=150; pre[4][2][6][0]=60; pre[4][2][6][1]=60; pre[4][2][7][0]=10; pre[4][2][7][1]=10; pre[4][3][1][0]=17; pre[4][3][1][1]=17; pre[4][3][2][0]=170; pre[4][3][2][1]=170; pre[4][3][3][0]=765; pre[4][3][3][1]=765; pre[4][3][4][0]=2040; pre[4][3][4][1]=2040; pre[4][3][5][0]=3570; pre[4][3][5][1]=3570; pre[4][3][6][0]=4284; pre[4][3][6][1]=4284; pre[4][3][7][0]=3570; pre[4][3][7][1]=3570; pre[4][3][8][0]=2040; pre[4][3][8][1]=2040; pre[4][4][1][0]=24; pre[4][4][1][1]=24; pre[4][4][2][0]=336; pre[4][4][2][1]=336; pre[4][4][3][0]=2184; pre[4][4][3][1]=2184; pre[4][4][4][0]=8736; pre[4][4][4][1]=8736; pre[4][4][5][0]=24024; pre[4][4][5][1]=24024; pre[4][4][6][0]=48048; pre[4][4][6][1]=48048; pre[4][4][7][0]=72072; pre[4][4][7][1]=72072; pre[4][4][8][0]=82368; pre[4][4][8][1]=82368; pre[4][5][1][0]=31; pre[4][5][1][1]=31; pre[4][5][2][0]=558; pre[4][5][2][1]=558; pre[4][5][3][0]=4743; pre[4][5][3][1]=4743; pre[4][5][4][0]=25296; pre[4][5][4][1]=25296; pre[4][5][5][0]=94860; pre[4][5][5][1]=94860; pre[4][5][6][0]=265608; pre[4][5][6][1]=265608; pre[4][5][7][0]=575484; pre[4][5][7][1]=575484; pre[4][5][8][0]=986544; pre[4][5][8][1]=986544; pre[4][6][1][0]=38; pre[4][6][1][1]=38; pre[4][6][2][0]=836; pre[4][6][2][1]=836; pre[4][6][3][0]=8778; pre[4][6][3][1]=8778; pre[4][6][4][0]=58520; pre[4][6][4][1]=58520; pre[4][6][5][0]=277970; pre[4][6][5][1]=277970; pre[4][6][6][0]=1000692; pre[4][6][6][1]=1000692; pre[4][6][7][0]=2835294; pre[4][6][7][1]=2835294; pre[4][6][8][0]=6480672; pre[4][6][8][1]=6480672; pre[4][7][1][0]=45; pre[4][7][1][1]=45; pre[4][7][2][0]=1170; pre[4][7][2][1]=1170; pre[4][7][3][0]=14625; pre[4][7][3][1]=14625; pre[4][7][4][0]=117000; pre[4][7][4][1]=117000; pre[4][7][5][0]=672750; pre[4][7][5][1]=672750; pre[4][7][6][0]=2960100; pre[4][7][6][1]=2960100; pre[4][7][7][0]=10360350; pre[4][7][7][1]=10360350; pre[4][7][8][0]=29601000; pre[4][7][8][1]=29601000; pre[4][8][1][0]=52; pre[4][8][1][1]=52; pre[4][8][2][0]=1560; pre[4][8][2][1]=1560; pre[4][8][3][0]=22620; pre[4][8][3][1]=22620; pre[4][8][4][0]=211120; pre[4][8][4][1]=211120; pre[4][8][5][0]=1425060; pre[4][8][5][1]=1425060; pre[4][8][6][0]=7410312; pre[4][8][6][1]=7410312; pre[4][8][7][0]=30876300; pre[4][8][7][1]=30876300; pre[4][8][8][0]=105861600; pre[4][8][8][1]=105861600; pre[5][1][1][0]=4; pre[5][1][1][1]=4; pre[5][1][2][0]=12; pre[5][1][2][1]=12; pre[5][1][3][0]=12; pre[5][1][3][1]=12; pre[5][1][4][0]=4; pre[5][1][4][1]=4; pre[5][2][1][0]=13; pre[5][2][1][1]=13; pre[5][2][2][0]=104; pre[5][2][2][1]=104; pre[5][2][3][0]=364; pre[5][2][3][1]=364; pre[5][2][4][0]=728; pre[5][2][4][1]=728; pre[5][2][5][0]=910; pre[5][2][5][1]=910; pre[5][2][6][0]=728; pre[5][2][6][1]=728; pre[5][2][7][0]=364; pre[5][2][7][1]=364; pre[5][2][8][0]=104; pre[5][2][8][1]=104; pre[5][3][1][0]=22; pre[5][3][1][1]=22; pre[5][3][2][0]=286; pre[5][3][2][1]=286; pre[5][3][3][0]=1716; pre[5][3][3][1]=1716; pre[5][3][4][0]=6292; pre[5][3][4][1]=6292; pre[5][3][5][0]=15730; pre[5][3][5][1]=15730; pre[5][3][6][0]=28314; pre[5][3][6][1]=28314; pre[5][3][7][0]=37752; pre[5][3][7][1]=37752; pre[5][3][8][0]=37752; pre[5][3][8][1]=37752; pre[5][4][1][0]=31; pre[5][4][1][1]=31; pre[5][4][2][0]=558; pre[5][4][2][1]=558; pre[5][4][3][0]=4743; pre[5][4][3][1]=4743; pre[5][4][4][0]=25296; pre[5][4][4][1]=25296; pre[5][4][5][0]=94860; pre[5][4][5][1]=94860; pre[5][4][6][0]=265608; pre[5][4][6][1]=265608; pre[5][4][7][0]=575484; pre[5][4][7][1]=575484; pre[5][4][8][0]=986544; pre[5][4][8][1]=986544; pre[5][5][1][0]=40; pre[5][5][1][1]=40; pre[5][5][2][0]=920; pre[5][5][2][1]=920; pre[5][5][3][0]=10120; pre[5][5][3][1]=10120; pre[5][5][4][0]=70840; pre[5][5][4][1]=70840; pre[5][5][5][0]=354200; pre[5][5][5][1]=354200; pre[5][5][6][0]=1345960; pre[5][5][6][1]=1345960; pre[5][5][7][0]=4037880; pre[5][5][7][1]=4037880; pre[5][5][8][0]=9806280; pre[5][5][8][1]=9806280; pre[5][6][1][0]=49; pre[5][6][1][1]=49; pre[5][6][2][0]=1372; pre[5][6][2][1]=1372; pre[5][6][3][0]=18522; pre[5][6][3][1]=18522; pre[5][6][4][0]=160524; pre[5][6][4][1]=160524; pre[5][6][5][0]=1003275; pre[5][6][5][1]=1003275; pre[5][6][6][0]=4815720; pre[5][6][6][1]=4815720; pre[5][6][7][0]=18460260; pre[5][6][7][1]=18460260; pre[5][6][8][0]=58017960; pre[5][6][8][1]=58017960; pre[5][7][1][0]=58; pre[5][7][1][1]=58; pre[5][7][2][0]=1914; pre[5][7][2][1]=1914; pre[5][7][3][0]=30624; pre[5][7][3][1]=30624; pre[5][7][4][0]=316448; pre[5][7][4][1]=316448; pre[5][7][5][0]=2373360; pre[5][7][5][1]=2373360; pre[5][7][6][0]=13765488; pre[5][7][6][1]=13765488; pre[5][7][7][0]=64238944; pre[5][7][7][1]=64238944; pre[5][7][8][0]=247778784; pre[5][7][8][1]=247778784; pre[5][8][1][0]=67; pre[5][8][1][1]=67; pre[5][8][2][0]=2546; pre[5][8][2][1]=2546; pre[5][8][3][0]=47101; pre[5][8][3][1]=47101; pre[5][8][4][0]=565212; pre[5][8][4][1]=565212; pre[5][8][5][0]=4945605; pre[5][8][5][1]=4945605; pre[5][8][6][0]=33630114; pre[5][8][6][1]=33630114; pre[5][8][7][0]=184965627; pre[5][8][7][1]=184965627; pre[5][8][8][0]=845557152; pre[5][8][8][1]=845557152; pre[6][1][1][0]=5; pre[6][1][1][1]=5; pre[6][1][2][0]=20; pre[6][1][2][1]=20; pre[6][1][3][0]=30; pre[6][1][3][1]=30; pre[6][1][4][0]=20; pre[6][1][4][1]=20; pre[6][1][5][0]=5; pre[6][1][5][1]=5; pre[6][2][1][0]=16; pre[6][2][1][1]=16; pre[6][2][2][0]=160; pre[6][2][2][1]=160; pre[6][2][3][0]=720; pre[6][2][3][1]=720; pre[6][2][4][0]=1920; pre[6][2][4][1]=1920; pre[6][2][5][0]=3360; pre[6][2][5][1]=3360; pre[6][2][6][0]=4032; pre[6][2][6][1]=4032; pre[6][2][7][0]=3360; pre[6][2][7][1]=3360; pre[6][2][8][0]=1920; pre[6][2][8][1]=1920; pre[6][3][1][0]=27; pre[6][3][1][1]=27; pre[6][3][2][0]=432; pre[6][3][2][1]=432; pre[6][3][3][0]=3240; pre[6][3][3][1]=3240; pre[6][3][4][0]=15120; pre[6][3][4][1]=15120; pre[6][3][5][0]=49140; pre[6][3][5][1]=49140; pre[6][3][6][0]=117936; pre[6][3][6][1]=117936; pre[6][3][7][0]=216216; pre[6][3][7][1]=216216; pre[6][3][8][0]=308880; pre[6][3][8][1]=308880; pre[6][4][1][0]=38; pre[6][4][1][1]=38; pre[6][4][2][0]=836; pre[6][4][2][1]=836; pre[6][4][3][0]=8778; pre[6][4][3][1]=8778; pre[6][4][4][0]=58520; pre[6][4][4][1]=58520; pre[6][4][5][0]=277970; pre[6][4][5][1]=277970; pre[6][4][6][0]=1000692; pre[6][4][6][1]=1000692; pre[6][4][7][0]=2835294; pre[6][4][7][1]=2835294; pre[6][4][8][0]=6480672; pre[6][4][8][1]=6480672; pre[6][5][1][0]=49; pre[6][5][1][1]=49; pre[6][5][2][0]=1372; pre[6][5][2][1]=1372; pre[6][5][3][0]=18522; pre[6][5][3][1]=18522; pre[6][5][4][0]=160524; pre[6][5][4][1]=160524; pre[6][5][5][0]=1003275; pre[6][5][5][1]=1003275; pre[6][5][6][0]=4815720; pre[6][5][6][1]=4815720; pre[6][5][7][0]=18460260; pre[6][5][7][1]=18460260; pre[6][5][8][0]=58017960; pre[6][5][8][1]=58017960; pre[6][6][1][0]=60; pre[6][6][1][1]=60; pre[6][6][2][0]=2040; pre[6][6][2][1]=2040; pre[6][6][3][0]=33660; pre[6][6][3][1]=33660; pre[6][6][4][0]=359040; pre[6][6][4][1]=359040; pre[6][6][5][0]=2782560; pre[6][6][5][1]=2782560; pre[6][6][6][0]=16695360; pre[6][6][6][1]=16695360; pre[6][6][7][0]=80694240; pre[6][6][7][1]=80694240; pre[6][6][8][0]=322776960; pre[6][6][8][1]=322776960; pre[6][7][1][0]=71; pre[6][7][1][1]=71; pre[6][7][2][0]=2840; pre[6][7][2][1]=2840; pre[6][7][3][0]=55380; pre[6][7][3][1]=55380; pre[6][7][4][0]=701480; pre[6][7][4][1]=701480; pre[6][7][5][0]=6488690; pre[6][7][5][1]=6488690; pre[6][7][6][0]=46718568; pre[6][7][6][1]=46718568; pre[6][7][7][0]=272524980; pre[6][7][7][1]=272524980; pre[6][7][8][0]=1323692760; pre[6][7][8][1]=1323692760; pre[6][8][1][0]=82; pre[6][8][1][1]=82; pre[6][8][2][0]=3772; pre[6][8][2][1]=3772; pre[6][8][3][0]=84870; pre[6][8][3][1]=84870; pre[6][8][4][0]=1244760; pre[6][8][4][1]=1244760; pre[6][8][5][0]=13381170; pre[6][8][5][1]=13381170; pre[6][8][6][0]=112401828; pre[6][8][6][1]=112401828; pre[6][8][7][0]=768079158; pre[6][8][7][1]=768079158; pre[6][8][8][0]=4389023760; pre[6][8][8][1]=4389023760; pre[7][1][1][0]=6; pre[7][1][1][1]=6; pre[7][1][2][0]=30; pre[7][1][2][1]=30; pre[7][1][3][0]=60; pre[7][1][3][1]=60; pre[7][1][4][0]=60; pre[7][1][4][1]=60; pre[7][1][5][0]=30; pre[7][1][5][1]=30; pre[7][1][6][0]=6; pre[7][1][6][1]=6; pre[7][2][1][0]=19; pre[7][2][1][1]=19; pre[7][2][2][0]=228; pre[7][2][2][1]=228; pre[7][2][3][0]=1254; pre[7][2][3][1]=1254; pre[7][2][4][0]=4180; pre[7][2][4][1]=4180; pre[7][2][5][0]=9405; pre[7][2][5][1]=9405; pre[7][2][6][0]=15048; pre[7][2][6][1]=15048; pre[7][2][7][0]=17556; pre[7][2][7][1]=17556; pre[7][2][8][0]=15048; pre[7][2][8][1]=15048; pre[7][3][1][0]=32; pre[7][3][1][1]=32; pre[7][3][2][0]=608; pre[7][3][2][1]=608; pre[7][3][3][0]=5472; pre[7][3][3][1]=5472; pre[7][3][4][0]=31008; pre[7][3][4][1]=31008; pre[7][3][5][0]=124032; pre[7][3][5][1]=124032; pre[7][3][6][0]=372096; pre[7][3][6][1]=372096; pre[7][3][7][0]=868224; pre[7][3][7][1]=868224; pre[7][3][8][0]=1612416; pre[7][3][8][1]=1612416; pre[7][4][1][0]=45; pre[7][4][1][1]=45; pre[7][4][2][0]=1170; pre[7][4][2][1]=1170; pre[7][4][3][0]=14625; pre[7][4][3][1]=14625; pre[7][4][4][0]=117000; pre[7][4][4][1]=117000; pre[7][4][5][0]=672750; pre[7][4][5][1]=672750; pre[7][4][6][0]=2960100; pre[7][4][6][1]=2960100; pre[7][4][7][0]=10360350; pre[7][4][7][1]=10360350; pre[7][4][8][0]=29601000; pre[7][4][8][1]=29601000; pre[7][5][1][0]=58; pre[7][5][1][1]=58; pre[7][5][2][0]=1914; pre[7][5][2][1]=1914; pre[7][5][3][0]=30624; pre[7][5][3][1]=30624; pre[7][5][4][0]=316448; pre[7][5][4][1]=316448; pre[7][5][5][0]=2373360; pre[7][5][5][1]=2373360; pre[7][5][6][0]=13765488; pre[7][5][6][1]=13765488; pre[7][5][7][0]=64238944; pre[7][5][7][1]=64238944; pre[7][5][8][0]=247778784; pre[7][5][8][1]=247778784; pre[7][6][1][0]=71; pre[7][6][1][1]=71; pre[7][6][2][0]=2840; pre[7][6][2][1]=2840; pre[7][6][3][0]=55380; pre[7][6][3][1]=55380; pre[7][6][4][0]=701480; pre[7][6][4][1]=701480; pre[7][6][5][0]=6488690; pre[7][6][5][1]=6488690; pre[7][6][6][0]=46718568; pre[7][6][6][1]=46718568; pre[7][6][7][0]=272524980; pre[7][6][7][1]=272524980; pre[7][6][8][0]=1323692760; pre[7][6][8][1]=1323692760; pre[7][7][1][0]=84; pre[7][7][1][1]=84; pre[7][7][2][0]=3948; pre[7][7][2][1]=3948; pre[7][7][3][0]=90804; pre[7][7][3][1]=90804; pre[7][7][4][0]=1362060; pre[7][7][4][1]=1362060; pre[7][7][5][0]=14982660; pre[7][7][5][1]=14982660; pre[7][7][6][0]=128850876; pre[7][7][6][1]=128850876; pre[7][7][7][0]=901956132; pre[7][7][7][1]=901956132; pre[7][7][8][0]=5282885916; pre[7][7][8][1]=5282885916; pre[7][8][1][0]=97; pre[7][8][1][1]=97; pre[7][8][2][0]=5238; pre[7][8][2][1]=5238; pre[7][8][3][0]=138807; pre[7][8][3][1]=138807; pre[7][8][4][0]=2405988; pre[7][8][4][1]=2405988; pre[7][8][5][0]=30676347; pre[7][8][5][1]=30676347; pre[7][8][6][0]=306763470; pre[7][8][6][1]=306763470; pre[7][8][7][0]=2505235005; pre[7][8][7][1]=2505235005; pre[7][8][8][0]=17178754320; pre[7][8][8][1]=17178754320; pre[8][1][1][0]=7; pre[8][1][1][1]=7; pre[8][1][2][0]=42; pre[8][1][2][1]=42; pre[8][1][3][0]=105; pre[8][1][3][1]=105; pre[8][1][4][0]=140; pre[8][1][4][1]=140; pre[8][1][5][0]=105; pre[8][1][5][1]=105; pre[8][1][6][0]=42; pre[8][1][6][1]=42; pre[8][1][7][0]=7; pre[8][1][7][1]=7; pre[8][2][1][0]=22; pre[8][2][1][1]=22; pre[8][2][2][0]=308; pre[8][2][2][1]=308; pre[8][2][3][0]=2002; pre[8][2][3][1]=2002; pre[8][2][4][0]=8008; pre[8][2][4][1]=8008; pre[8][2][5][0]=22022; pre[8][2][5][1]=22022; pre[8][2][6][0]=44044; pre[8][2][6][1]=44044; pre[8][2][7][0]=66066; pre[8][2][7][1]=66066; pre[8][2][8][0]=75504; pre[8][2][8][1]=75504; pre[8][3][1][0]=37; pre[8][3][1][1]=37; pre[8][3][2][0]=814; pre[8][3][2][1]=814; pre[8][3][3][0]=8547; pre[8][3][3][1]=8547; pre[8][3][4][0]=56980; pre[8][3][4][1]=56980; pre[8][3][5][0]=270655; pre[8][3][5][1]=270655; pre[8][3][6][0]=974358; pre[8][3][6][1]=974358; pre[8][3][7][0]=2760681; pre[8][3][7][1]=2760681; pre[8][3][8][0]=6310128; pre[8][3][8][1]=6310128; pre[8][4][1][0]=52; pre[8][4][1][1]=52; pre[8][4][2][0]=1560; pre[8][4][2][1]=1560; pre[8][4][3][0]=22620; pre[8][4][3][1]=22620; pre[8][4][4][0]=211120; pre[8][4][4][1]=211120; pre[8][4][5][0]=1425060; pre[8][4][5][1]=1425060; pre[8][4][6][0]=7410312; pre[8][4][6][1]=7410312; pre[8][4][7][0]=30876300; pre[8][4][7][1]=30876300; pre[8][4][8][0]=105861600; pre[8][4][8][1]=105861600; pre[8][5][1][0]=67; pre[8][5][1][1]=67; pre[8][5][2][0]=2546; pre[8][5][2][1]=2546; pre[8][5][3][0]=47101; pre[8][5][3][1]=47101; pre[8][5][4][0]=565212; pre[8][5][4][1]=565212; pre[8][5][5][0]=4945605; pre[8][5][5][1]=4945605; pre[8][5][6][0]=33630114; pre[8][5][6][1]=33630114; pre[8][5][7][0]=184965627; pre[8][5][7][1]=184965627; pre[8][5][8][0]=845557152; pre[8][5][8][1]=845557152; pre[8][6][1][0]=82; pre[8][6][1][1]=82; pre[8][6][2][0]=3772; pre[8][6][2][1]=3772; pre[8][6][3][0]=84870; pre[8][6][3][1]=84870; pre[8][6][4][0]=1244760; pre[8][6][4][1]=1244760; pre[8][6][5][0]=13381170; pre[8][6][5][1]=13381170; pre[8][6][6][0]=112401828; pre[8][6][6][1]=112401828; pre[8][6][7][0]=768079158; pre[8][6][7][1]=768079158; pre[8][6][8][0]=4389023760; pre[8][6][8][1]=4389023760; pre[8][7][1][0]=97; pre[8][7][1][1]=97; pre[8][7][2][0]=5238; pre[8][7][2][1]=5238; pre[8][7][3][0]=138807; pre[8][7][3][1]=138807; pre[8][7][4][0]=2405988; pre[8][7][4][1]=2405988; pre[8][7][5][0]=30676347; pre[8][7][5][1]=30676347; pre[8][7][6][0]=306763470; pre[8][7][6][1]=306763470; pre[8][7][7][0]=2505235005; pre[8][7][7][1]=2505235005; pre[8][7][8][0]=17178754320; pre[8][7][8][1]=17178754320; pre[8][8][1][0]=112; pre[8][8][1][1]=112; pre[8][8][2][0]=6944; pre[8][8][2][1]=6944; pre[8][8][3][0]=211792; pre[8][8][3][1]=211792; pre[8][8][4][0]=4235840; pre[8][8][4][1]=4235840; pre[8][8][5][0]=62478640; pre[8][8][5][1]=62478640; pre[8][8][6][0]=724752224; pre[8][8][6][1]=724752224; pre[8][8][7][0]=6885146128; pre[8][8][7][1]=6885146128; pre[8][8][8][0]=55081169024; pre[8][8][8][1]=55081169024; // ll i; cin>>n>>m; int ilepionkow = 0; int ilebialych= 0; for (i = 0; i < n; i++){ string s; cin>>s; for (int j = 0; j < m; j++){ if (s[j] == 'O'){ ilepionkow++; if (!((i+j)%2)) ilebialych++; } } } wy = pre[n][m][ilepionkow][ilebialych%2]; // cout<<wy<<"\n"; string koniec[n]; int ilep = 0; int ileb = 0; for (i = 0; i < n; i++) cin>>koniec[i]; long long deg = 0; for (i = 0; i < n; i++){ for (int j = 0; j < m; j++){ if (koniec[i][j] == 'O'){ ilep++; //cout<<i+j<<"\n"; if (!((i+j)%2)) ileb++; if (i && koniec[i-1][j] == '.') deg++; if (j && koniec[i][j-1] == '.') deg++; if (i != n-1 && koniec[i+1][j] == '.') deg++; if (j != m-1 && koniec[i][j+1] == '.') deg++; } } } //cout<<wy<<"\n"; // cout<<ilep<<" "<<ilepionkow<<" # "<<ileb<<" "<<ilebialych<<"\n"; if (ilep != ilepionkow || ((ileb-ilebialych)%2+2)%2){ cout<<"0\n"; return 0; } //cout<<wy<<"\n"; cout<<fixed<<setprecision(15)<<(long double)deg/(long double)wy<<"\n"; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 | #include <bits/stdc++.h> using namespace std; typedef long long ll; //Autor: Michał Szeliga #ifdef LOCAL #define debug(...) __VA_ARGS__; #else #define debug(...) {} #endif //PREPROCESSING ll pre[9][9][9][2]; // ll n =7; ll m = 6; ll wy; ll odw = 0; ll dwu[101][101]; ll policznewton(ll n, ll k){ __int128 wy = 1; if (!n || !k) return 1; for (ll i = max(k,n-k)+1; i <= n; i++) wy *= i; for (ll i = 1; i <= min(k,n-k); i++) wy /= i; return wy; } ll dwumian(ll n, ll k){ return dwu[n][k]; } void policz(vector<pair<ll,ll> > pozycje, int ilepionkow, int ilebialych){ if ((ll)pozycje.size() == ilebialych){ //cerr<<odw<<"\n"; ll ilenpar = ilepionkow-ilebialych; odw++; bool tab[n][m]; ll delta[n][m]; for (ll i = 0; i < n; i++){ for (ll j = 0; j < m; j++){ delta[i][j] = 4; if (!i) delta[i][j]--; if (!j) delta[i][j]--; if (i == n-1) delta[i][j]--; if (j == m-1) delta[i][j]--; tab[i][j] = 0; } } //cout<<"DLA CIĄGU: \n"; for (auto j : pozycje){ tab[j.first][j.second] = 1; //cout<<j.first<<" "<<j.second<<" # "; } //cout<<" wynikiem jest "; ll deg = 0; vector<ll> val; for (ll i = 0; i < n; i++){ for (ll j = 0; j < m; j++){ if (tab[i][j] == 0) continue; if (i){ deg++; delta[i-1][j] -= 2; } if (j){ deg++; delta[i][j-1] -= 2; } if (i < n-1){ deg++; delta[i+1][j] -= 2; } if (j < m-1){ deg++; delta[i][j+1] -= 2; } } } for (ll i = 0; i < n; i++) for (ll j = 0; j < m; j++) if (!tab[i][j] && (i+j)%2) val.push_back(delta[i][j]); ll DL = val.size(); wy += deg*dwumian(DL, ilenpar); //cout<<"\n"; for (ll i = 0; i < DL; i++){ //cout<<val[i]<<" "; for (ll j = 0; j < ilenpar; j++){ if (i < j || DL-i-1 < ilenpar-j-1) continue; //cout<<i<<" "<<val[i]<<" # "<<j<<" ### "<<val[i]*dwumian(i,j)*dwumian(DL-i-1,ilenpar-j-1)<<"\n"; wy += val[i]*dwumian(i,j)*dwumian(DL-i-1,ilenpar-j-1); } } // cout<<wy[ilebialych][ilenpar]-xd<<"\n"; //exit(0); //cout<<"DLA PIONKÓW deg = "<<deg<<"\n"; /*for (auto j : pozycje){ cout<<j.first<<" "<<j.second<<" # "; } cout<<"\n";*/ return; } ll x = 0; ll y = -1; if (pozycje.size()){ x = pozycje.back().first; y = pozycje.back().second; } for (ll i = x; i < n; i++){ for (ll j = i%2; j < m; j += 2){ if (i == x && j <= y) continue; pozycje.push_back({i,j}); policz(pozycje,ilepionkow,ilebialych); pozycje.pop_back(); } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); debug(freopen("wietest/in/125.in","r",stdin);); //PREPROCESSING pre[1][2][1][0]=1; pre[1][2][1][1]=1; pre[1][3][1][0]=2; pre[1][3][1][1]=2; pre[1][3][2][0]=2; pre[1][3][2][1]=2; pre[1][4][1][0]=3; pre[1][4][1][1]=3; pre[1][4][2][0]=6; pre[1][4][2][1]=6; pre[1][4][3][0]=3; pre[1][4][3][1]=3; pre[1][5][1][0]=4; pre[1][5][1][1]=4; pre[1][5][2][0]=12; pre[1][5][2][1]=12; pre[1][5][3][0]=12; pre[1][5][3][1]=12; pre[1][5][4][0]=4; pre[1][5][4][1]=4; pre[1][6][1][0]=5; pre[1][6][1][1]=5; pre[1][6][2][0]=20; pre[1][6][2][1]=20; pre[1][6][3][0]=30; pre[1][6][3][1]=30; pre[1][6][4][0]=20; pre[1][6][4][1]=20; pre[1][6][5][0]=5; pre[1][6][5][1]=5; pre[1][7][1][0]=6; pre[1][7][1][1]=6; pre[1][7][2][0]=30; pre[1][7][2][1]=30; pre[1][7][3][0]=60; pre[1][7][3][1]=60; pre[1][7][4][0]=60; pre[1][7][4][1]=60; pre[1][7][5][0]=30; pre[1][7][5][1]=30; pre[1][7][6][0]=6; pre[1][7][6][1]=6; pre[1][8][1][0]=7; pre[1][8][1][1]=7; pre[1][8][2][0]=42; pre[1][8][2][1]=42; pre[1][8][3][0]=105; pre[1][8][3][1]=105; pre[1][8][4][0]=140; pre[1][8][4][1]=140; pre[1][8][5][0]=105; pre[1][8][5][1]=105; pre[1][8][6][0]=42; pre[1][8][6][1]=42; pre[1][8][7][0]=7; pre[1][8][7][1]=7; pre[2][1][1][0]=1; pre[2][1][1][1]=1; pre[2][2][1][0]=4; pre[2][2][1][1]=4; pre[2][2][2][0]=8; pre[2][2][2][1]=8; pre[2][2][3][0]=4; pre[2][2][3][1]=4; pre[2][3][1][0]=7; pre[2][3][1][1]=7; pre[2][3][2][0]=28; pre[2][3][2][1]=28; pre[2][3][3][0]=42; pre[2][3][3][1]=42; pre[2][3][4][0]=28; pre[2][3][4][1]=28; pre[2][3][5][0]=7; pre[2][3][5][1]=7; pre[2][4][1][0]=10; pre[2][4][1][1]=10; pre[2][4][2][0]=60; pre[2][4][2][1]=60; pre[2][4][3][0]=150; pre[2][4][3][1]=150; pre[2][4][4][0]=200; pre[2][4][4][1]=200; pre[2][4][5][0]=150; pre[2][4][5][1]=150; pre[2][4][6][0]=60; pre[2][4][6][1]=60; pre[2][4][7][0]=10; pre[2][4][7][1]=10; pre[2][5][1][0]=13; pre[2][5][1][1]=13; pre[2][5][2][0]=104; pre[2][5][2][1]=104; pre[2][5][3][0]=364; pre[2][5][3][1]=364; pre[2][5][4][0]=728; pre[2][5][4][1]=728; pre[2][5][5][0]=910; pre[2][5][5][1]=910; pre[2][5][6][0]=728; pre[2][5][6][1]=728; pre[2][5][7][0]=364; pre[2][5][7][1]=364; pre[2][5][8][0]=104; pre[2][5][8][1]=104; pre[2][6][1][0]=16; pre[2][6][1][1]=16; pre[2][6][2][0]=160; pre[2][6][2][1]=160; pre[2][6][3][0]=720; pre[2][6][3][1]=720; pre[2][6][4][0]=1920; pre[2][6][4][1]=1920; pre[2][6][5][0]=3360; pre[2][6][5][1]=3360; pre[2][6][6][0]=4032; pre[2][6][6][1]=4032; pre[2][6][7][0]=3360; pre[2][6][7][1]=3360; pre[2][6][8][0]=1920; pre[2][6][8][1]=1920; pre[2][7][1][0]=19; pre[2][7][1][1]=19; pre[2][7][2][0]=228; pre[2][7][2][1]=228; pre[2][7][3][0]=1254; pre[2][7][3][1]=1254; pre[2][7][4][0]=4180; pre[2][7][4][1]=4180; pre[2][7][5][0]=9405; pre[2][7][5][1]=9405; pre[2][7][6][0]=15048; pre[2][7][6][1]=15048; pre[2][7][7][0]=17556; pre[2][7][7][1]=17556; pre[2][7][8][0]=15048; pre[2][7][8][1]=15048; pre[2][8][1][0]=22; pre[2][8][1][1]=22; pre[2][8][2][0]=308; pre[2][8][2][1]=308; pre[2][8][3][0]=2002; pre[2][8][3][1]=2002; pre[2][8][4][0]=8008; pre[2][8][4][1]=8008; pre[2][8][5][0]=22022; pre[2][8][5][1]=22022; pre[2][8][6][0]=44044; pre[2][8][6][1]=44044; pre[2][8][7][0]=66066; pre[2][8][7][1]=66066; pre[2][8][8][0]=75504; pre[2][8][8][1]=75504; pre[3][1][1][0]=2; pre[3][1][1][1]=2; pre[3][1][2][0]=2; pre[3][1][2][1]=2; pre[3][2][1][0]=7; pre[3][2][1][1]=7; pre[3][2][2][0]=28; pre[3][2][2][1]=28; pre[3][2][3][0]=42; pre[3][2][3][1]=42; pre[3][2][4][0]=28; pre[3][2][4][1]=28; pre[3][2][5][0]=7; pre[3][2][5][1]=7; pre[3][3][1][0]=12; pre[3][3][1][1]=12; pre[3][3][2][0]=84; pre[3][3][2][1]=84; pre[3][3][3][0]=252; pre[3][3][3][1]=252; pre[3][3][4][0]=420; pre[3][3][4][1]=420; pre[3][3][5][0]=420; pre[3][3][5][1]=420; pre[3][3][6][0]=252; pre[3][3][6][1]=252; pre[3][3][7][0]=84; pre[3][3][7][1]=84; pre[3][3][8][0]=12; pre[3][3][8][1]=12; pre[3][4][1][0]=17; pre[3][4][1][1]=17; pre[3][4][2][0]=170; pre[3][4][2][1]=170; pre[3][4][3][0]=765; pre[3][4][3][1]=765; pre[3][4][4][0]=2040; pre[3][4][4][1]=2040; pre[3][4][5][0]=3570; pre[3][4][5][1]=3570; pre[3][4][6][0]=4284; pre[3][4][6][1]=4284; pre[3][4][7][0]=3570; pre[3][4][7][1]=3570; pre[3][4][8][0]=2040; pre[3][4][8][1]=2040; pre[3][5][1][0]=22; pre[3][5][1][1]=22; pre[3][5][2][0]=286; pre[3][5][2][1]=286; pre[3][5][3][0]=1716; pre[3][5][3][1]=1716; pre[3][5][4][0]=6292; pre[3][5][4][1]=6292; pre[3][5][5][0]=15730; pre[3][5][5][1]=15730; pre[3][5][6][0]=28314; pre[3][5][6][1]=28314; pre[3][5][7][0]=37752; pre[3][5][7][1]=37752; pre[3][5][8][0]=37752; pre[3][5][8][1]=37752; pre[3][6][1][0]=27; pre[3][6][1][1]=27; pre[3][6][2][0]=432; pre[3][6][2][1]=432; pre[3][6][3][0]=3240; pre[3][6][3][1]=3240; pre[3][6][4][0]=15120; pre[3][6][4][1]=15120; pre[3][6][5][0]=49140; pre[3][6][5][1]=49140; pre[3][6][6][0]=117936; pre[3][6][6][1]=117936; pre[3][6][7][0]=216216; pre[3][6][7][1]=216216; pre[3][6][8][0]=308880; pre[3][6][8][1]=308880; pre[3][7][1][0]=32; pre[3][7][1][1]=32; pre[3][7][2][0]=608; pre[3][7][2][1]=608; pre[3][7][3][0]=5472; pre[3][7][3][1]=5472; pre[3][7][4][0]=31008; pre[3][7][4][1]=31008; pre[3][7][5][0]=124032; pre[3][7][5][1]=124032; pre[3][7][6][0]=372096; pre[3][7][6][1]=372096; pre[3][7][7][0]=868224; pre[3][7][7][1]=868224; pre[3][7][8][0]=1612416; pre[3][7][8][1]=1612416; pre[3][8][1][0]=37; pre[3][8][1][1]=37; pre[3][8][2][0]=814; pre[3][8][2][1]=814; pre[3][8][3][0]=8547; pre[3][8][3][1]=8547; pre[3][8][4][0]=56980; pre[3][8][4][1]=56980; pre[3][8][5][0]=270655; pre[3][8][5][1]=270655; pre[3][8][6][0]=974358; pre[3][8][6][1]=974358; pre[3][8][7][0]=2760681; pre[3][8][7][1]=2760681; pre[3][8][8][0]=6310128; pre[3][8][8][1]=6310128; pre[4][1][1][0]=3; pre[4][1][1][1]=3; pre[4][1][2][0]=6; pre[4][1][2][1]=6; pre[4][1][3][0]=3; pre[4][1][3][1]=3; pre[4][2][1][0]=10; pre[4][2][1][1]=10; pre[4][2][2][0]=60; pre[4][2][2][1]=60; pre[4][2][3][0]=150; pre[4][2][3][1]=150; pre[4][2][4][0]=200; pre[4][2][4][1]=200; pre[4][2][5][0]=150; pre[4][2][5][1]=150; pre[4][2][6][0]=60; pre[4][2][6][1]=60; pre[4][2][7][0]=10; pre[4][2][7][1]=10; pre[4][3][1][0]=17; pre[4][3][1][1]=17; pre[4][3][2][0]=170; pre[4][3][2][1]=170; pre[4][3][3][0]=765; pre[4][3][3][1]=765; pre[4][3][4][0]=2040; pre[4][3][4][1]=2040; pre[4][3][5][0]=3570; pre[4][3][5][1]=3570; pre[4][3][6][0]=4284; pre[4][3][6][1]=4284; pre[4][3][7][0]=3570; pre[4][3][7][1]=3570; pre[4][3][8][0]=2040; pre[4][3][8][1]=2040; pre[4][4][1][0]=24; pre[4][4][1][1]=24; pre[4][4][2][0]=336; pre[4][4][2][1]=336; pre[4][4][3][0]=2184; pre[4][4][3][1]=2184; pre[4][4][4][0]=8736; pre[4][4][4][1]=8736; pre[4][4][5][0]=24024; pre[4][4][5][1]=24024; pre[4][4][6][0]=48048; pre[4][4][6][1]=48048; pre[4][4][7][0]=72072; pre[4][4][7][1]=72072; pre[4][4][8][0]=82368; pre[4][4][8][1]=82368; pre[4][5][1][0]=31; pre[4][5][1][1]=31; pre[4][5][2][0]=558; pre[4][5][2][1]=558; pre[4][5][3][0]=4743; pre[4][5][3][1]=4743; pre[4][5][4][0]=25296; pre[4][5][4][1]=25296; pre[4][5][5][0]=94860; pre[4][5][5][1]=94860; pre[4][5][6][0]=265608; pre[4][5][6][1]=265608; pre[4][5][7][0]=575484; pre[4][5][7][1]=575484; pre[4][5][8][0]=986544; pre[4][5][8][1]=986544; pre[4][6][1][0]=38; pre[4][6][1][1]=38; pre[4][6][2][0]=836; pre[4][6][2][1]=836; pre[4][6][3][0]=8778; pre[4][6][3][1]=8778; pre[4][6][4][0]=58520; pre[4][6][4][1]=58520; pre[4][6][5][0]=277970; pre[4][6][5][1]=277970; pre[4][6][6][0]=1000692; pre[4][6][6][1]=1000692; pre[4][6][7][0]=2835294; pre[4][6][7][1]=2835294; pre[4][6][8][0]=6480672; pre[4][6][8][1]=6480672; pre[4][7][1][0]=45; pre[4][7][1][1]=45; pre[4][7][2][0]=1170; pre[4][7][2][1]=1170; pre[4][7][3][0]=14625; pre[4][7][3][1]=14625; pre[4][7][4][0]=117000; pre[4][7][4][1]=117000; pre[4][7][5][0]=672750; pre[4][7][5][1]=672750; pre[4][7][6][0]=2960100; pre[4][7][6][1]=2960100; pre[4][7][7][0]=10360350; pre[4][7][7][1]=10360350; pre[4][7][8][0]=29601000; pre[4][7][8][1]=29601000; pre[4][8][1][0]=52; pre[4][8][1][1]=52; pre[4][8][2][0]=1560; pre[4][8][2][1]=1560; pre[4][8][3][0]=22620; pre[4][8][3][1]=22620; pre[4][8][4][0]=211120; pre[4][8][4][1]=211120; pre[4][8][5][0]=1425060; pre[4][8][5][1]=1425060; pre[4][8][6][0]=7410312; pre[4][8][6][1]=7410312; pre[4][8][7][0]=30876300; pre[4][8][7][1]=30876300; pre[4][8][8][0]=105861600; pre[4][8][8][1]=105861600; pre[5][1][1][0]=4; pre[5][1][1][1]=4; pre[5][1][2][0]=12; pre[5][1][2][1]=12; pre[5][1][3][0]=12; pre[5][1][3][1]=12; pre[5][1][4][0]=4; pre[5][1][4][1]=4; pre[5][2][1][0]=13; pre[5][2][1][1]=13; pre[5][2][2][0]=104; pre[5][2][2][1]=104; pre[5][2][3][0]=364; pre[5][2][3][1]=364; pre[5][2][4][0]=728; pre[5][2][4][1]=728; pre[5][2][5][0]=910; pre[5][2][5][1]=910; pre[5][2][6][0]=728; pre[5][2][6][1]=728; pre[5][2][7][0]=364; pre[5][2][7][1]=364; pre[5][2][8][0]=104; pre[5][2][8][1]=104; pre[5][3][1][0]=22; pre[5][3][1][1]=22; pre[5][3][2][0]=286; pre[5][3][2][1]=286; pre[5][3][3][0]=1716; pre[5][3][3][1]=1716; pre[5][3][4][0]=6292; pre[5][3][4][1]=6292; pre[5][3][5][0]=15730; pre[5][3][5][1]=15730; pre[5][3][6][0]=28314; pre[5][3][6][1]=28314; pre[5][3][7][0]=37752; pre[5][3][7][1]=37752; pre[5][3][8][0]=37752; pre[5][3][8][1]=37752; pre[5][4][1][0]=31; pre[5][4][1][1]=31; pre[5][4][2][0]=558; pre[5][4][2][1]=558; pre[5][4][3][0]=4743; pre[5][4][3][1]=4743; pre[5][4][4][0]=25296; pre[5][4][4][1]=25296; pre[5][4][5][0]=94860; pre[5][4][5][1]=94860; pre[5][4][6][0]=265608; pre[5][4][6][1]=265608; pre[5][4][7][0]=575484; pre[5][4][7][1]=575484; pre[5][4][8][0]=986544; pre[5][4][8][1]=986544; pre[5][5][1][0]=40; pre[5][5][1][1]=40; pre[5][5][2][0]=920; pre[5][5][2][1]=920; pre[5][5][3][0]=10120; pre[5][5][3][1]=10120; pre[5][5][4][0]=70840; pre[5][5][4][1]=70840; pre[5][5][5][0]=354200; pre[5][5][5][1]=354200; pre[5][5][6][0]=1345960; pre[5][5][6][1]=1345960; pre[5][5][7][0]=4037880; pre[5][5][7][1]=4037880; pre[5][5][8][0]=9806280; pre[5][5][8][1]=9806280; pre[5][6][1][0]=49; pre[5][6][1][1]=49; pre[5][6][2][0]=1372; pre[5][6][2][1]=1372; pre[5][6][3][0]=18522; pre[5][6][3][1]=18522; pre[5][6][4][0]=160524; pre[5][6][4][1]=160524; pre[5][6][5][0]=1003275; pre[5][6][5][1]=1003275; pre[5][6][6][0]=4815720; pre[5][6][6][1]=4815720; pre[5][6][7][0]=18460260; pre[5][6][7][1]=18460260; pre[5][6][8][0]=58017960; pre[5][6][8][1]=58017960; pre[5][7][1][0]=58; pre[5][7][1][1]=58; pre[5][7][2][0]=1914; pre[5][7][2][1]=1914; pre[5][7][3][0]=30624; pre[5][7][3][1]=30624; pre[5][7][4][0]=316448; pre[5][7][4][1]=316448; pre[5][7][5][0]=2373360; pre[5][7][5][1]=2373360; pre[5][7][6][0]=13765488; pre[5][7][6][1]=13765488; pre[5][7][7][0]=64238944; pre[5][7][7][1]=64238944; pre[5][7][8][0]=247778784; pre[5][7][8][1]=247778784; pre[5][8][1][0]=67; pre[5][8][1][1]=67; pre[5][8][2][0]=2546; pre[5][8][2][1]=2546; pre[5][8][3][0]=47101; pre[5][8][3][1]=47101; pre[5][8][4][0]=565212; pre[5][8][4][1]=565212; pre[5][8][5][0]=4945605; pre[5][8][5][1]=4945605; pre[5][8][6][0]=33630114; pre[5][8][6][1]=33630114; pre[5][8][7][0]=184965627; pre[5][8][7][1]=184965627; pre[5][8][8][0]=845557152; pre[5][8][8][1]=845557152; pre[6][1][1][0]=5; pre[6][1][1][1]=5; pre[6][1][2][0]=20; pre[6][1][2][1]=20; pre[6][1][3][0]=30; pre[6][1][3][1]=30; pre[6][1][4][0]=20; pre[6][1][4][1]=20; pre[6][1][5][0]=5; pre[6][1][5][1]=5; pre[6][2][1][0]=16; pre[6][2][1][1]=16; pre[6][2][2][0]=160; pre[6][2][2][1]=160; pre[6][2][3][0]=720; pre[6][2][3][1]=720; pre[6][2][4][0]=1920; pre[6][2][4][1]=1920; pre[6][2][5][0]=3360; pre[6][2][5][1]=3360; pre[6][2][6][0]=4032; pre[6][2][6][1]=4032; pre[6][2][7][0]=3360; pre[6][2][7][1]=3360; pre[6][2][8][0]=1920; pre[6][2][8][1]=1920; pre[6][3][1][0]=27; pre[6][3][1][1]=27; pre[6][3][2][0]=432; pre[6][3][2][1]=432; pre[6][3][3][0]=3240; pre[6][3][3][1]=3240; pre[6][3][4][0]=15120; pre[6][3][4][1]=15120; pre[6][3][5][0]=49140; pre[6][3][5][1]=49140; pre[6][3][6][0]=117936; pre[6][3][6][1]=117936; pre[6][3][7][0]=216216; pre[6][3][7][1]=216216; pre[6][3][8][0]=308880; pre[6][3][8][1]=308880; pre[6][4][1][0]=38; pre[6][4][1][1]=38; pre[6][4][2][0]=836; pre[6][4][2][1]=836; pre[6][4][3][0]=8778; pre[6][4][3][1]=8778; pre[6][4][4][0]=58520; pre[6][4][4][1]=58520; pre[6][4][5][0]=277970; pre[6][4][5][1]=277970; pre[6][4][6][0]=1000692; pre[6][4][6][1]=1000692; pre[6][4][7][0]=2835294; pre[6][4][7][1]=2835294; pre[6][4][8][0]=6480672; pre[6][4][8][1]=6480672; pre[6][5][1][0]=49; pre[6][5][1][1]=49; pre[6][5][2][0]=1372; pre[6][5][2][1]=1372; pre[6][5][3][0]=18522; pre[6][5][3][1]=18522; pre[6][5][4][0]=160524; pre[6][5][4][1]=160524; pre[6][5][5][0]=1003275; pre[6][5][5][1]=1003275; pre[6][5][6][0]=4815720; pre[6][5][6][1]=4815720; pre[6][5][7][0]=18460260; pre[6][5][7][1]=18460260; pre[6][5][8][0]=58017960; pre[6][5][8][1]=58017960; pre[6][6][1][0]=60; pre[6][6][1][1]=60; pre[6][6][2][0]=2040; pre[6][6][2][1]=2040; pre[6][6][3][0]=33660; pre[6][6][3][1]=33660; pre[6][6][4][0]=359040; pre[6][6][4][1]=359040; pre[6][6][5][0]=2782560; pre[6][6][5][1]=2782560; pre[6][6][6][0]=16695360; pre[6][6][6][1]=16695360; pre[6][6][7][0]=80694240; pre[6][6][7][1]=80694240; pre[6][6][8][0]=322776960; pre[6][6][8][1]=322776960; pre[6][7][1][0]=71; pre[6][7][1][1]=71; pre[6][7][2][0]=2840; pre[6][7][2][1]=2840; pre[6][7][3][0]=55380; pre[6][7][3][1]=55380; pre[6][7][4][0]=701480; pre[6][7][4][1]=701480; pre[6][7][5][0]=6488690; pre[6][7][5][1]=6488690; pre[6][7][6][0]=46718568; pre[6][7][6][1]=46718568; pre[6][7][7][0]=272524980; pre[6][7][7][1]=272524980; pre[6][7][8][0]=1323692760; pre[6][7][8][1]=1323692760; pre[6][8][1][0]=82; pre[6][8][1][1]=82; pre[6][8][2][0]=3772; pre[6][8][2][1]=3772; pre[6][8][3][0]=84870; pre[6][8][3][1]=84870; pre[6][8][4][0]=1244760; pre[6][8][4][1]=1244760; pre[6][8][5][0]=13381170; pre[6][8][5][1]=13381170; pre[6][8][6][0]=112401828; pre[6][8][6][1]=112401828; pre[6][8][7][0]=768079158; pre[6][8][7][1]=768079158; pre[6][8][8][0]=4389023760; pre[6][8][8][1]=4389023760; pre[7][1][1][0]=6; pre[7][1][1][1]=6; pre[7][1][2][0]=30; pre[7][1][2][1]=30; pre[7][1][3][0]=60; pre[7][1][3][1]=60; pre[7][1][4][0]=60; pre[7][1][4][1]=60; pre[7][1][5][0]=30; pre[7][1][5][1]=30; pre[7][1][6][0]=6; pre[7][1][6][1]=6; pre[7][2][1][0]=19; pre[7][2][1][1]=19; pre[7][2][2][0]=228; pre[7][2][2][1]=228; pre[7][2][3][0]=1254; pre[7][2][3][1]=1254; pre[7][2][4][0]=4180; pre[7][2][4][1]=4180; pre[7][2][5][0]=9405; pre[7][2][5][1]=9405; pre[7][2][6][0]=15048; pre[7][2][6][1]=15048; pre[7][2][7][0]=17556; pre[7][2][7][1]=17556; pre[7][2][8][0]=15048; pre[7][2][8][1]=15048; pre[7][3][1][0]=32; pre[7][3][1][1]=32; pre[7][3][2][0]=608; pre[7][3][2][1]=608; pre[7][3][3][0]=5472; pre[7][3][3][1]=5472; pre[7][3][4][0]=31008; pre[7][3][4][1]=31008; pre[7][3][5][0]=124032; pre[7][3][5][1]=124032; pre[7][3][6][0]=372096; pre[7][3][6][1]=372096; pre[7][3][7][0]=868224; pre[7][3][7][1]=868224; pre[7][3][8][0]=1612416; pre[7][3][8][1]=1612416; pre[7][4][1][0]=45; pre[7][4][1][1]=45; pre[7][4][2][0]=1170; pre[7][4][2][1]=1170; pre[7][4][3][0]=14625; pre[7][4][3][1]=14625; pre[7][4][4][0]=117000; pre[7][4][4][1]=117000; pre[7][4][5][0]=672750; pre[7][4][5][1]=672750; pre[7][4][6][0]=2960100; pre[7][4][6][1]=2960100; pre[7][4][7][0]=10360350; pre[7][4][7][1]=10360350; pre[7][4][8][0]=29601000; pre[7][4][8][1]=29601000; pre[7][5][1][0]=58; pre[7][5][1][1]=58; pre[7][5][2][0]=1914; pre[7][5][2][1]=1914; pre[7][5][3][0]=30624; pre[7][5][3][1]=30624; pre[7][5][4][0]=316448; pre[7][5][4][1]=316448; pre[7][5][5][0]=2373360; pre[7][5][5][1]=2373360; pre[7][5][6][0]=13765488; pre[7][5][6][1]=13765488; pre[7][5][7][0]=64238944; pre[7][5][7][1]=64238944; pre[7][5][8][0]=247778784; pre[7][5][8][1]=247778784; pre[7][6][1][0]=71; pre[7][6][1][1]=71; pre[7][6][2][0]=2840; pre[7][6][2][1]=2840; pre[7][6][3][0]=55380; pre[7][6][3][1]=55380; pre[7][6][4][0]=701480; pre[7][6][4][1]=701480; pre[7][6][5][0]=6488690; pre[7][6][5][1]=6488690; pre[7][6][6][0]=46718568; pre[7][6][6][1]=46718568; pre[7][6][7][0]=272524980; pre[7][6][7][1]=272524980; pre[7][6][8][0]=1323692760; pre[7][6][8][1]=1323692760; pre[7][7][1][0]=84; pre[7][7][1][1]=84; pre[7][7][2][0]=3948; pre[7][7][2][1]=3948; pre[7][7][3][0]=90804; pre[7][7][3][1]=90804; pre[7][7][4][0]=1362060; pre[7][7][4][1]=1362060; pre[7][7][5][0]=14982660; pre[7][7][5][1]=14982660; pre[7][7][6][0]=128850876; pre[7][7][6][1]=128850876; pre[7][7][7][0]=901956132; pre[7][7][7][1]=901956132; pre[7][7][8][0]=5282885916; pre[7][7][8][1]=5282885916; pre[7][8][1][0]=97; pre[7][8][1][1]=97; pre[7][8][2][0]=5238; pre[7][8][2][1]=5238; pre[7][8][3][0]=138807; pre[7][8][3][1]=138807; pre[7][8][4][0]=2405988; pre[7][8][4][1]=2405988; pre[7][8][5][0]=30676347; pre[7][8][5][1]=30676347; pre[7][8][6][0]=306763470; pre[7][8][6][1]=306763470; pre[7][8][7][0]=2505235005; pre[7][8][7][1]=2505235005; pre[7][8][8][0]=17178754320; pre[7][8][8][1]=17178754320; pre[8][1][1][0]=7; pre[8][1][1][1]=7; pre[8][1][2][0]=42; pre[8][1][2][1]=42; pre[8][1][3][0]=105; pre[8][1][3][1]=105; pre[8][1][4][0]=140; pre[8][1][4][1]=140; pre[8][1][5][0]=105; pre[8][1][5][1]=105; pre[8][1][6][0]=42; pre[8][1][6][1]=42; pre[8][1][7][0]=7; pre[8][1][7][1]=7; pre[8][2][1][0]=22; pre[8][2][1][1]=22; pre[8][2][2][0]=308; pre[8][2][2][1]=308; pre[8][2][3][0]=2002; pre[8][2][3][1]=2002; pre[8][2][4][0]=8008; pre[8][2][4][1]=8008; pre[8][2][5][0]=22022; pre[8][2][5][1]=22022; pre[8][2][6][0]=44044; pre[8][2][6][1]=44044; pre[8][2][7][0]=66066; pre[8][2][7][1]=66066; pre[8][2][8][0]=75504; pre[8][2][8][1]=75504; pre[8][3][1][0]=37; pre[8][3][1][1]=37; pre[8][3][2][0]=814; pre[8][3][2][1]=814; pre[8][3][3][0]=8547; pre[8][3][3][1]=8547; pre[8][3][4][0]=56980; pre[8][3][4][1]=56980; pre[8][3][5][0]=270655; pre[8][3][5][1]=270655; pre[8][3][6][0]=974358; pre[8][3][6][1]=974358; pre[8][3][7][0]=2760681; pre[8][3][7][1]=2760681; pre[8][3][8][0]=6310128; pre[8][3][8][1]=6310128; pre[8][4][1][0]=52; pre[8][4][1][1]=52; pre[8][4][2][0]=1560; pre[8][4][2][1]=1560; pre[8][4][3][0]=22620; pre[8][4][3][1]=22620; pre[8][4][4][0]=211120; pre[8][4][4][1]=211120; pre[8][4][5][0]=1425060; pre[8][4][5][1]=1425060; pre[8][4][6][0]=7410312; pre[8][4][6][1]=7410312; pre[8][4][7][0]=30876300; pre[8][4][7][1]=30876300; pre[8][4][8][0]=105861600; pre[8][4][8][1]=105861600; pre[8][5][1][0]=67; pre[8][5][1][1]=67; pre[8][5][2][0]=2546; pre[8][5][2][1]=2546; pre[8][5][3][0]=47101; pre[8][5][3][1]=47101; pre[8][5][4][0]=565212; pre[8][5][4][1]=565212; pre[8][5][5][0]=4945605; pre[8][5][5][1]=4945605; pre[8][5][6][0]=33630114; pre[8][5][6][1]=33630114; pre[8][5][7][0]=184965627; pre[8][5][7][1]=184965627; pre[8][5][8][0]=845557152; pre[8][5][8][1]=845557152; pre[8][6][1][0]=82; pre[8][6][1][1]=82; pre[8][6][2][0]=3772; pre[8][6][2][1]=3772; pre[8][6][3][0]=84870; pre[8][6][3][1]=84870; pre[8][6][4][0]=1244760; pre[8][6][4][1]=1244760; pre[8][6][5][0]=13381170; pre[8][6][5][1]=13381170; pre[8][6][6][0]=112401828; pre[8][6][6][1]=112401828; pre[8][6][7][0]=768079158; pre[8][6][7][1]=768079158; pre[8][6][8][0]=4389023760; pre[8][6][8][1]=4389023760; pre[8][7][1][0]=97; pre[8][7][1][1]=97; pre[8][7][2][0]=5238; pre[8][7][2][1]=5238; pre[8][7][3][0]=138807; pre[8][7][3][1]=138807; pre[8][7][4][0]=2405988; pre[8][7][4][1]=2405988; pre[8][7][5][0]=30676347; pre[8][7][5][1]=30676347; pre[8][7][6][0]=306763470; pre[8][7][6][1]=306763470; pre[8][7][7][0]=2505235005; pre[8][7][7][1]=2505235005; pre[8][7][8][0]=17178754320; pre[8][7][8][1]=17178754320; pre[8][8][1][0]=112; pre[8][8][1][1]=112; pre[8][8][2][0]=6944; pre[8][8][2][1]=6944; pre[8][8][3][0]=211792; pre[8][8][3][1]=211792; pre[8][8][4][0]=4235840; pre[8][8][4][1]=4235840; pre[8][8][5][0]=62478640; pre[8][8][5][1]=62478640; pre[8][8][6][0]=724752224; pre[8][8][6][1]=724752224; pre[8][8][7][0]=6885146128; pre[8][8][7][1]=6885146128; pre[8][8][8][0]=55081169024; pre[8][8][8][1]=55081169024; // ll i; cin>>n>>m; int ilepionkow = 0; int ilebialych= 0; for (i = 0; i < n; i++){ string s; cin>>s; for (int j = 0; j < m; j++){ if (s[j] == 'O'){ ilepionkow++; if (!((i+j)%2)) ilebialych++; } } } wy = pre[n][m][ilepionkow][ilebialych%2]; // cout<<wy<<"\n"; string koniec[n]; int ilep = 0; int ileb = 0; for (i = 0; i < n; i++) cin>>koniec[i]; long long deg = 0; for (i = 0; i < n; i++){ for (int j = 0; j < m; j++){ if (koniec[i][j] == 'O'){ ilep++; //cout<<i+j<<"\n"; if (!((i+j)%2)) ileb++; if (i && koniec[i-1][j] == '.') deg++; if (j && koniec[i][j-1] == '.') deg++; if (i != n-1 && koniec[i+1][j] == '.') deg++; if (j != m-1 && koniec[i][j+1] == '.') deg++; } } } //cout<<wy<<"\n"; // cout<<ilep<<" "<<ilepionkow<<" # "<<ileb<<" "<<ilebialych<<"\n"; if (ilep != ilepionkow || ((ileb-ilebialych)%2+2)%2){ cout<<"0\n"; return 0; } //cout<<wy<<"\n"; cout<<fixed<<setprecision(15)<<(long double)deg/(long double)wy<<"\n"; return 0; } |