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

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

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

b = A("b")
h = B("h")
e = C("e")
c = B("c")
m = C("m")
n = A("n")
f = C("f")
a = A("a")
j = B("j")

b.x = c
b.s = m
h.u = e
e.z = a
c.u = m
m.z = b
n.x = h
n.s = m
f.z = b
a.x = c
a.s = m
j.u = m
assert n.x.u.z.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

b = A("b")
h = B("h")
e = C("e")
c = B("c")
m = C("m")
n = A("n")
f = C("f")
a = A("a")
j = B("j")

b.x = c
b.s = m
h.u = e
e.z = a
c.u = m
m.z = b
n.x = h
n.s = m
f.z = b
a.x = c
a.s = m
j.u = m
assert n.x.u.z.x.u.txt == "m"