Solution 1:

I did a quick redstone work. I think that you will compact it. I will explain it anyway.

there are 4 output states. (not considering 0th state)

1st state -> block in front of white wool

2nd state -> block in front of megenta wool

3rd state -> block in front of yellow wool

4th state -> block in front of blue wool

mechanism:

an dropper is facing in hopper. also hopper is facing in the dropper. so when the hopper is unlocked, swords will flow into the dropper.

the input button is not visible in this image. it is on the sandstone block directly next to the dropper.

when you press input button once , sword gets dropped in the hopper, the signal strength of comparator increases and you get output as stage 1. on second press you get output state 2, and so on...

when you are in 4th state and press the button again, hopper gets filled with anoter sword, thus signal strength of comparator increases and with the pulse extender piston retracts thus flushing all swords from hopper back to dropper.

enter image description here

enter image description here