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

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

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

g = A("g")
c = B("c")
b = C("b")
j = B("j")
m = B("m")
e = A("e")
k = C("k")
n = C("n")
h = A("h")

g.w = h
c.w = k
c.z = n
b.o = j
j.w = n
j.z = n
m.w = n
m.z = n
e.w = g
k.o = c
n.o = m
h.w = e
assert c.w.o.w.o.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
b = C("b")
j = B("j")
m = B("m")
e = A("e")
k = C("k")
n = C("n")
h = A("h")

g.w = h
c.w = k
c.z = n
b.o = j
j.w = n
j.z = n
m.w = n
m.z = n
e.w = g
k.o = c
n.o = m
h.w = e
assert c.w.o.w.o.z.o.z.txt == "n"