Tricky node masking problems - Seasoning for plants

So I have a general problem: I have two different b&w masks created with several nodes. First one is a gradient from top to bottom

Second one is a mask that assignes different colors to each individual part of the mesh and then using this changes each one from white to black, so that with the slider set to 0 you have all white, the slider set to 1 all black and for example .5 parts black and parts white

Is there a way to combine those two masks, so that the individual parts get black from the bottom to the top? So that first parts that will change are the ones close to the ground and the last ones are the ones on the top?

If it doesn’t work that way, is there any other way to do this?