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

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

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

m = A("m")
f = B("f")
c = C("c")
n = B("n")
h = A("h")

m.w = n
f.r = n
f.t = c
c.s = n
n.r = f
n.t = c
h.w = f
assert c.s.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

m = A("m")
f = B("f")
c = C("c")
n = B("n")
h = A("h")

m.w = n
f.r = n
f.t = c
c.s = n
n.r = f
n.t = c
h.w = f
assert c.s.r.r.txt == "n"