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

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

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

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

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

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

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

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

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