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

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

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

l = A("l")
m = B("m")
a = C("a")
e = B("e")
b = A("b")
k = B("k")
j = A("j")

l.z = j
l.o = b
m.z = a
a.z = b
a.q = m
e.z = a
b.z = j
b.o = l
k.z = a
j.z = b
j.o = b
assert j.o.o.o.z.o.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.o: A = None
        self.txt = txt

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

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

l = A("l")
m = B("m")
a = C("a")
e = B("e")
b = A("b")
k = B("k")
j = A("j")

l.z = j
l.o = b
m.z = a
a.z = b
a.q = m
e.z = a
b.z = j
b.o = l
k.z = a
j.z = b
j.o = b
assert j.o.o.o.z.o.z.z.txt == "b"