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

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

b.z = h
b.x = m
l.s = b
d.x = l
m.z = h
m.x = b
c.x = l
h.z = m
h.x = b
k.x = l
j.x = l
assert h.z.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = 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.x: B = None
        self.txt = txt

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

b.z = h
b.x = m
l.s = b
d.x = l
m.z = h
m.x = b
c.x = l
h.z = m
h.x = b
k.x = l
j.x = l
assert h.z.z.x.z.txt == "h"