new function to generate the AND of all the run masks