give rectangular pizza represent row x col matrix contain follow character a apple cell give integer k you cut pizza k piece k1 cut for cut choose direction vertical horizontal choose cut position cell boundary cut pizza piece if cut pizza vertically leave pizza person if cut pizza horizontally upper pizza person give piece pizza personreturn number way cut pizza piece contain apple since answer huge number return modulo 109 7 Example 1input pizza AAAA k 3output 3 Explanation the figure show way cut pizza note piece contain appleexample 2input pizza AAA k 3Output 1Example 3input pizza AA k 1Output 1 Constraints1 row col 50rows pizzalengthcol pizzailength1 k 10pizza consist character a