In the picture below the polygons are color coded after their layer attribute. Obviously there is something wrong. Didn't dig too deep for now, might also be the case for other p,q combinations.