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

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

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

j = A("j")
d = B("d")
k = C("k")
m = C("m")
g = A("g")
n = B("n")
l = A("l")
i = C("i")

j.z = m
j.y = n
d.v = n
k.v = g
m.v = l
g.z = m
g.y = n
n.v = d
l.z = i
l.y = n
i.v = l
assert m.v.z.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: B = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
k = C("k")
m = C("m")
g = A("g")
n = B("n")
l = A("l")
i = C("i")

j.z = m
j.y = n
d.v = n
k.v = g
m.v = l
g.z = m
g.y = n
n.v = d
l.z = i
l.y = n
i.v = l
assert m.v.z.v.y.v.txt == "d"