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

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

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

k = A("k")
f = B("f")
c = C("c")
e = B("e")
b = C("b")
d = A("d")
j = B("j")
m = C("m")
l = B("l")

k.z = m
k.w = d
f.z = d
f.q = k
c.w = k
c.z = k
c.r = m
e.z = d
e.q = d
b.w = k
b.z = d
b.r = m
d.z = b
d.w = k
j.z = k
j.q = k
m.w = d
m.z = k
m.r = c
l.z = d
l.q = d
assert l.q.z.w.z.w.w.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.w: A = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
c = C("c")
e = B("e")
b = C("b")
d = A("d")
j = B("j")
m = C("m")
l = B("l")

k.z = m
k.w = d
f.z = d
f.q = k
c.w = k
c.z = k
c.r = m
e.z = d
e.q = d
b.w = k
b.z = d
b.r = m
d.z = b
d.w = k
j.z = k
j.q = k
m.w = d
m.z = k
m.r = c
l.z = d
l.q = d
assert l.q.z.w.z.w.w.w.z.txt == "b"