m@main=do s<-getLine;putStrLn$do n<-zipWith(++)`scanl1`scanr((:).(:[]))[]s>>=map read;show$product[2..n-2]^2`mod`max 1n m