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

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

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

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

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

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

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

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

d.w = e
d.q = l
h.z = d
h.o = l
h.y = e
e.p = g
m.p = g
l.z = g
l.o = a
l.y = m
n.w = m
n.q = h
g.w = m
g.q = h
a.z = d
a.o = l
a.y = e
b.z = n
b.o = a
b.y = m
assert l.z.w.p.w.p.txt == "g"