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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: B = None
        self.txt = txt

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

a = A("a")
m = B("m")
f = C("f")
k = B("k")
c = B("c")
j = C("j")
d = C("d")
l = A("l")
h = A("h")
g = B("g")

a.q = k
a.z = j
a.w = c
m.p = j
m.q = g
f.z = d
k.p = j
k.q = m
c.p = d
c.q = g
j.z = d
d.z = f
l.q = g
l.w = g
l.z = f
h.q = c
h.z = d
h.w = g
g.p = d
g.q = m
assert c.p.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: C = None
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: B = None
        self.txt = txt

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

a = A("a")
m = B("m")
f = C("f")
k = B("k")
c = B("c")
j = C("j")
d = C("d")
l = A("l")
h = A("h")
g = B("g")

a.q = k
a.z = j
a.w = c
m.p = j
m.q = g
f.z = d
k.p = j
k.q = m
c.p = d
c.q = g
j.z = d
d.z = f
l.q = g
l.w = g
l.z = f
h.q = c
h.z = d
h.w = g
g.p = d
g.q = m
assert c.p.z.z.z.txt == "f"