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

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

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

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

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

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

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

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

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