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

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

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

a = A("a")
m = B("m")
k = C("k")
d = B("d")
f = C("f")
b = A("b")
j = B("j")
l = A("l")
g = A("g")

a.w = g
a.p = f
m.o = j
m.p = d
m.x = k
k.z = a
d.o = m
d.p = m
d.x = f
f.z = l
b.w = l
b.p = f
j.o = d
j.p = m
j.x = k
l.w = a
l.p = f
g.w = a
g.p = k
assert m.o.p.p.o.x.z.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.p: C = None
        self.txt = txt

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

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

a = A("a")
m = B("m")
k = C("k")
d = B("d")
f = C("f")
b = A("b")
j = B("j")
l = A("l")
g = A("g")

a.w = g
a.p = f
m.o = j
m.p = d
m.x = k
k.z = a
d.o = m
d.p = m
d.x = f
f.z = l
b.w = l
b.p = f
j.o = d
j.p = m
j.x = k
l.w = a
l.p = f
g.w = a
g.p = k
assert m.o.p.p.o.x.z.p.z.txt == "l"