Vertical and horizontal simon task

I am new to Psychopy and I am trying to build a Simon Task consisting of 2 item-sets 1 horizontal set (1, 4, 6, 9) and a vertical set (2, 3, 7, 8). It means that the numbers of the horizonzal set can appear on the left or right side of the screen and the numbers of the vertical set can appear at the top or at the button.

The difficulty is that the sets should switch after each trial (horizontal - vertical - horizontal - veritcal) but the numbers of each set should appear randomly on either the left/right or top/down site of the screen. Task is to tell if the presented number is < 5 participants reacht with the arrow keys.

I tried to build a loop with 2 routines in it (1 horizonzal 1 vertical) but in that case it pairs the sets so if in the vertical set 1 was presented it Always presents 3 in the horizontal set.

Do you have any ideas how to build an Experiment like this? Thank you in advance!