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

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

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

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

l.w = b
l.z = d
b.z = n
b.x = n
d.w = n
d.q = j
d.o = j
j.w = n
j.q = d
j.o = c
f.w = b
f.z = j
c.w = b
c.q = j
c.o = d
e.w = n
e.z = c
n.z = b
n.x = b
assert d.w.x.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: C = None
        self.txt = txt

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

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

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

l.w = b
l.z = d
b.z = n
b.x = n
d.w = n
d.q = j
d.o = j
j.w = n
j.q = d
j.o = c
f.w = b
f.z = j
c.w = b
c.q = j
c.o = d
e.w = n
e.z = c
n.z = b
n.x = b
assert d.w.x.z.x.z.txt == "n"