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

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

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

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

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

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

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

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

n.z = m
n.p = g
m.w = g
b.o = a
b.u = a
h.o = a
h.u = a
j.o = a
j.u = a
f.z = m
f.p = m
d.o = n
d.u = n
k.o = n
k.u = a
a.z = g
a.p = g
g.w = m
assert d.o.p.w.w.w.w.w.w.w.w.txt == "g"