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

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

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

i = A("i")
a = B("a")
m = C("m")
c = B("c")
d = C("d")
f = C("f")

i.q = a
i.y = a
a.z = c
a.w = c
m.w = f
m.u = i
m.o = c
c.z = a
c.w = a
d.w = f
d.u = i
d.o = a
f.w = m
f.u = i
f.o = c
assert f.w.o.z.w.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: B = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
m = C("m")
c = B("c")
d = C("d")
f = C("f")

i.q = a
i.y = a
a.z = c
a.w = c
m.w = f
m.u = i
m.o = c
c.z = a
c.w = a
d.w = f
d.u = i
d.o = a
f.w = m
f.u = i
f.o = c
assert f.w.o.z.w.z.z.txt == "c"