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

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

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

b = A("b")
d = B("d")
f = C("f")
l = B("l")
i = A("i")
a = C("a")
c = A("c")
m = A("m")
h = B("h")
e = B("e")

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

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

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

b = A("b")
d = B("d")
f = C("f")
l = B("l")
i = A("i")
a = C("a")
c = A("c")
m = A("m")
h = B("h")
e = B("e")

b.v = f
b.z = d
d.z = h
f.w = m
f.q = b
f.y = a
l.z = d
i.v = f
i.z = l
a.w = m
a.q = m
a.y = f
c.v = a
c.z = d
m.v = f
m.z = h
h.z = e
e.z = d
assert a.y.q.v.w.z.z.z.txt == "d"