#![allow(non_snake_case, unused_imports, unused_must_use)] use std::io::{self, prelude::*}; use std::str; fn main() { let (stdin, stdout) = (io::stdin(), io::stdout()); let mut scan = Scanner::new(stdin.lock()); let mut out = io::BufWriter::new(stdout.lock()); macro_rules! input { ($T: ty) => { scan.token::<$T>() }; ($T: ty, $N: expr) => { (0..$N).map(|_| scan.token::<$T>()).collect::>() }; } let H = input!(usize); let W = input!(usize); let A = (0..H) .map(|_| input!(String).chars().collect::>()) .collect::>(); let mut ans = 0_usize; for s in 0..1usize << (H + W - 2) { let mut hcnt = 0; let mut wcnt = 0; for i in 0..H + W - 2 { if (s >> i) & 1 == 1 { hcnt += 1; } else { wcnt += 1; } } if !(hcnt == H - 1 && wcnt == W - 1) { continue; } let mut jewelry = 1; let mut ny = 0; let mut nx = 0; let mut isok = true; for i in 0..H + W - 2 { if (s >> i) & 1 == 1 { ny += 1; if A[ny][nx] == 'o' { jewelry += 1; } else if A[ny][nx] == 'x' { jewelry -= 1; } else { isok = false; } } else { nx += 1; if A[ny][nx] == 'o' { jewelry += 1; } else if A[ny][nx] == 'x' { jewelry -= 1; } else { isok = false; } } if jewelry < 0 { isok = false; } } if isok { ans += 1; } } writeln!(out, "{}", ans); } struct Scanner { reader: R, buf_str: Vec, buf_iter: str::SplitWhitespace<'static>, } impl Scanner { fn new(reader: R) -> Self { Self { reader, buf_str: vec![], buf_iter: "".split_whitespace(), } } fn token(&mut self) -> T { loop { if let Some(token) = self.buf_iter.next() { return token.parse().ok().expect("Failed parse"); } self.buf_str.clear(); self.reader .read_until(b'\n', &mut self.buf_str) .expect("Failed read"); self.buf_iter = unsafe { let slice = str::from_utf8_unchecked(&self.buf_str); std::mem::transmute(slice.split_whitespace()) } } } }