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

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

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

h = A("h")
b = B("b")
j = C("j")
k = A("k")
i = A("i")
l = C("l")
e = B("e")
c = C("c")
n = A("n")
m = A("m")

h.z = j
h.v = b
b.w = e
j.y = m
k.z = l
k.v = b
i.z = j
i.v = b
l.y = n
e.w = b
c.y = n
n.z = c
n.v = e
m.z = l
m.v = b
assert m.v.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.txt = txt

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

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

h = A("h")
b = B("b")
j = C("j")
k = A("k")
i = A("i")
l = C("l")
e = B("e")
c = C("c")
n = A("n")
m = A("m")

h.z = j
h.v = b
b.w = e
j.y = m
k.z = l
k.v = b
i.z = j
i.v = b
l.y = n
e.w = b
c.y = n
n.z = c
n.v = e
m.z = l
m.v = b
assert m.v.w.w.txt == "b"