Isn't a circular array implemented with a modula to begin with? I don’t see how you bypass it
m3=m5=m7=1 for ... ... m3 = m3==2?0:m3+1 m5 = m5==4?0:m5+1 m7 = m7==6?0:m7+1
You keep two counters.