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

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

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

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

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

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

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

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

h.s = n
n.x = h
e.u = h
assert h.s.x.s.txt == "n"