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

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

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

f = A("f")
c = B("c")
e = C("e")
h = C("h")

f.o = c
c.u = h
c.x = h
e.u = h
e.z = c
e.s = f
h.u = e
h.z = c
h.s = f
assert h.s.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

f = A("f")
c = B("c")
e = C("e")
h = C("h")

f.o = c
c.u = h
c.x = h
e.u = h
e.z = c
e.s = f
h.u = e
h.z = c
h.s = f
assert h.s.o.u.txt == "h"