class A:
    def __init__(self, txt: str):
        self.x: 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.r: A = None
        self.txt = txt

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

m.x = h
a.s = d
h.r = m
l.x = h
n.s = d
c.s = m
d.x = h
assert n.s.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: 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.r: A = None
        self.txt = txt

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

m.x = h
a.s = d
h.r = m
l.x = h
n.s = d
c.s = m
d.x = h
assert n.s.x.r.x.txt == "h"