Question: Rewrite rules from lists

I have following lists

a,a,a,b,c
b,b,b,c,e
a,c,e,e,e
a,a,a,b,c
b,b,b,c,e
a,c,e,e,e
a,a,a,b,c
b,b,b,c,e
a,c,e,e,e
a,a,a,b,c

I want to write the bare rewrite rules for these so that if any list is given as input these rules produce the next one. It is obvious every third is same as first.

Please Wait...