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

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

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

c = A("c")
d = B("d")
j = C("j")
k = C("k")
b = C("b")
f = C("f")
m = A("m")
h = A("h")
l = A("l")
a = B("a")

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

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

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

c = A("c")
d = B("d")
j = C("j")
k = C("k")
b = C("b")
f = C("f")
m = A("m")
h = A("h")
l = A("l")
a = B("a")

c.o = h
d.w = k
d.s = f
d.p = a
j.s = m
j.z = a
j.x = a
k.s = m
k.z = d
k.x = d
b.s = m
b.z = d
b.x = a
f.s = h
f.z = a
f.x = d
m.o = c
h.o = l
l.o = h
a.w = j
a.s = k
a.p = d
assert k.x.p.p.p.s.s.o.o.o.o.txt == "h"