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

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

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

i = A("i")
f = B("f")
j = C("j")
g = C("g")
m = A("m")
k = A("k")
h = B("h")
l = B("l")
n = C("n")
c = A("c")

i.z = f
i.o = f
i.s = g
f.w = g
f.z = n
f.p = h
j.w = n
g.w = j
m.z = h
m.o = h
m.s = j
k.z = h
k.o = h
k.s = n
h.w = g
h.z = j
h.p = f
l.w = j
l.z = j
l.p = f
n.w = g
c.z = f
c.o = f
c.s = n
assert l.p.z.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: B = None
        self.s: C = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
j = C("j")
g = C("g")
m = A("m")
k = A("k")
h = B("h")
l = B("l")
n = C("n")
c = A("c")

i.z = f
i.o = f
i.s = g
f.w = g
f.z = n
f.p = h
j.w = n
g.w = j
m.z = h
m.o = h
m.s = j
k.z = h
k.o = h
k.s = n
h.w = g
h.z = j
h.p = f
l.w = j
l.z = j
l.p = f
n.w = g
c.z = f
c.o = f
c.s = n
assert l.p.z.w.w.w.w.w.txt == "j"