Cyclic Quine

A classic Quine is a program which outputs its own source code.
At first, such a program’s existence seems weird if not impossible, as it has to be so self-referential that it knows about itself everything, including how to know about itself. However, writing quines is possible, if not trivial.

A cyclic quine therefore is a program which outputs source code which differs from its own source code, yet outputs the original source code when run (the cycle length could be greater than one). So when running source codes \Psi and \Phi, they output source codes \Phi and \Psi.

Therefore, when one saves the first program as q0.py and the second as q1.py, one can create both source codes from one another (the following bash commands will not change the files’ contents).

$ python q0.py > q1.py
$ python q1.py > q0.py
$ python q0.py | python > q0.py
$ python q0.py | python | python | python | python > q1.py

j=0;Q,q="j=1;Q,q={}{}{}.replace(str(j),str(int(not(int(j)))),1),chr(34);print Q.format(q,Q,q)".replace(str(j),str(int(not(int(j)))),1),chr(34);print Q.format(q,Q,q)
j=1;Q,q="j=1;Q,q={}{}{}.replace(str(j),str(int(not(int(j)))),1),chr(34);print Q.format(q,Q,q)".replace(str(j),str(int(not(int(j)))),1),chr(34);print Q.format(q,Q,q)