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

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

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

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

d.p = n
d.o = e
k.w = a
m.z = d
b.z = a
e.z = a
n.w = d
l.w = a
a.p = k
a.o = e
assert a.o.z.p.w.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: C = None
        self.txt = txt

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

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

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

d.p = n
d.o = e
k.w = a
m.z = d
b.z = a
e.z = a
n.w = d
l.w = a
a.p = k
a.o = e
assert a.o.z.p.w.o.z.txt == "a"