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

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

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

h = A("h")
k = B("k")
d = C("d")
f = A("f")

h.x = k
h.r = k
h.u = d
k.t = d
d.s = f
f.x = k
f.r = k
f.u = d
assert d.s.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: B = None
        self.u: C = None
        self.txt = txt

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

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

h = A("h")
k = B("k")
d = C("d")
f = A("f")

h.x = k
h.r = k
h.u = d
k.t = d
d.s = f
f.x = k
f.r = k
f.u = d
assert d.s.u.s.txt == "f"