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

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

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

g = A("g")
e = B("e")
h = C("h")

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

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

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

g = A("g")
e = B("e")
h = C("h")

g.w = e
e.u = h
e.o = g
e.w = g
h.t = g
h.z = e
h.q = e
assert h.q.o.w.txt == "e"