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

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

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

m = A("m")
j = B("j")
h = C("h")
l = B("l")
n = A("n")
f = A("f")
b = A("b")
i = C("i")
d = C("d")
e = B("e")

m.z = e
m.u = n
j.z = m
h.s = m
h.p = e
h.r = f
l.z = b
n.z = e
n.u = m
f.z = l
f.u = m
b.z = e
b.u = m
i.s = b
i.p = l
i.r = n
d.s = n
d.p = l
d.r = b
e.z = n
assert b.z.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: A = None
        self.txt = txt

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

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

m = A("m")
j = B("j")
h = C("h")
l = B("l")
n = A("n")
f = A("f")
b = A("b")
i = C("i")
d = C("d")
e = B("e")

m.z = e
m.u = n
j.z = m
h.s = m
h.p = e
h.r = f
l.z = b
n.z = e
n.u = m
f.z = l
f.u = m
b.z = e
b.u = m
i.s = b
i.p = l
i.r = n
d.s = n
d.p = l
d.r = b
e.z = n
assert b.z.z.u.txt == "m"