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

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

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

j = A("j")
c = B("c")
d = C("d")
b = B("b")
f = B("f")
n = C("n")
e = A("e")
h = B("h")
m = C("m")

j.q = e
j.w = e
c.z = m
c.s = e
d.w = b
b.z = m
b.s = e
f.z = d
f.s = j
n.w = c
e.q = j
e.w = j
h.z = m
h.s = j
m.w = c
assert b.z.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: A = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
d = C("d")
b = B("b")
f = B("f")
n = C("n")
e = A("e")
h = B("h")
m = C("m")

j.q = e
j.w = e
c.z = m
c.s = e
d.w = b
b.z = m
b.s = e
f.z = d
f.s = j
n.w = c
e.q = j
e.w = j
h.z = m
h.s = j
m.w = c
assert b.z.w.z.w.txt == "c"