You can achieve the thing by:
First, Repeating On Grid using the Repeat codeblock (prismarine block), inside its chest put a Variable (preferably a LOCAL one), that variable will be the current block location, and put the 2 corners inside the chest. Then between the Sticky Pistons, place an If Game: Block Equals (If Game should be a Red Nether Brick), inside its chest, put your Variable in the first slot (as the location parameter), and put your blocks that you want to replace in the rest of the chest (you can put an air
Text if you want to replace air), now between the If Game's pistons, just place a Game Action: Set Region (I recommend Set Region rather than Set Block because it doesn't do any block updates, therefor consumes less CPU), and inside its chest put the same Variable twice (in the 1st and 2nd slot) and put your block in the 3rd slot and you should be done!