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

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

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

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

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

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

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

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

k.z = h
h.y = i
l.s = m
l.v = k
l.r = k
i.y = m
m.y = h
n.s = m
n.v = k
n.r = j
j.z = m
e.s = i
e.v = k
e.r = j
assert k.z.y.y.txt == "m"