class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: B = None
        self.txt = txt

e = A("e")
i = B("i")
g = B("g")
c = A("c")

e.u = i
e.q = i
i.o = c
i.t = g
g.o = e
g.t = i
c.u = g
c.q = g
assert c.q.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: B = None
        self.txt = txt

e = A("e")
i = B("i")
g = B("g")
c = A("c")

e.u = i
e.q = i
i.o = c
i.t = g
g.o = e
g.t = i
c.u = g
c.q = g
assert c.q.o.q.o.txt == "c"