number of paths on a grid with restrictions