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

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

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

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

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

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

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

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

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