l=[0..5] m@main=do s<-getLine;putStrLn$do x<-l;y<-l;(n,"")<-reads$take x$drop y s++" ";show$mod(product[1..n-1]^2)$n+0^n m