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

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

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

h = A("h")
m = B("m")
c = C("c")
l = A("l")
d = A("d")
k = A("k")

h.w = m
m.r = d
c.s = m
l.w = m
d.w = m
k.w = m
assert d.w.r.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

h = A("h")
m = B("m")
c = C("c")
l = A("l")
d = A("d")
k = A("k")

h.w = m
m.r = d
c.s = m
l.w = m
d.w = m
k.w = m
assert d.w.r.w.r.w.txt == "m"