I think the simplest solution is to perform a 3x3 grid depalletization using the UR template followed by an irregular palletization containing 9 items that represent your 5x4 pattern, also using the UR pattern.
Another option is to implement the destination as two single line patterns a 1x5 & 1x4. You can then either alternate between the patterns or complete one pattern followed by the other depending on the order you want them to be stacked.
Teach pose for top left position, PoseTL. Then each pose in pallet is just a vector translation in X and Y => PoseOffset=[X1,Y1,0,0,0,0]. PoseNext = postrans(PoseTL, PoseOffset). Top row just has X offset, Xn=X0+i*XOffset. Bottom row has X0+i*XOffset and Y=YOffset, where i=1..5 This is basic DIY palletizing the old school way.