$/=words;put (([$3-1,$4-1]X+($5-$2))Z%[$0,$1])X+1