Codeforces Round 630, 1332 E- Height All the Same | Competitive Coding


in this video we have to calulate grids. Total no of ways ( (r-l+1)nm) - No of ways(both are odd
(a and x-a) ). but this is for one grid i guess, (r-l+1)nm is no of ways of filling one grid f n*m. how is this giving answer of total grids?

Also correct me if i am wrong but if input is 1 2 1 3 then answer is 5 but why it cant be solved with 1 grid only? let the grid be :
|1 | 3 |
so i can directly add 2 cubes in 1 cell and height is same why need 5 grids?