class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: B = None
        self.s: B = 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: B = None
        self.y: B = None
        self.txt = txt

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

h.w = m
h.y = d
h.s = d
d.t = m
m.s = d
m.y = d
assert h.s.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: B = None
        self.s: B = 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: B = None
        self.y: B = None
        self.txt = txt

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

h.w = m
h.y = d
h.s = d
d.t = m
m.s = d
m.y = d
assert h.s.t.y.txt == "d"