class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: A = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
a = C("a")
c = A("c")
f = B("f")
e = C("e")
d = C("d")
l = B("l")

g.q = c
g.s = c
h.z = d
h.p = l
h.w = a
a.o = f
c.q = g
c.s = g
f.z = e
f.p = h
f.w = a
e.o = h
d.o = l
l.z = d
l.p = h
l.w = e
assert l.z.o.z.o.z.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: A = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
a = C("a")
c = A("c")
f = B("f")
e = C("e")
d = C("d")
l = B("l")

g.q = c
g.s = c
h.z = d
h.p = l
h.w = a
a.o = f
c.q = g
c.s = g
f.z = e
f.p = h
f.w = a
e.o = h
d.o = l
l.z = d
l.p = h
l.w = e
assert l.z.o.z.o.z.o.w.o.txt == "h"