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

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

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

b = A("b")
h = B("h")
i = C("i")
j = C("j")
d = B("d")
g = C("g")
k = A("k")
a = A("a")
l = C("l")
c = B("c")

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

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

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

b = A("b")
h = B("h")
i = C("i")
j = C("j")
d = B("d")
g = C("g")
k = A("k")
a = A("a")
l = C("l")
c = B("c")

b.w = k
b.s = g
h.p = j
h.z = j
h.o = c
i.p = k
i.s = k
j.p = k
j.s = b
d.p = g
d.o = c
d.z = j
g.p = k
g.s = b
k.w = a
k.s = g
a.w = k
a.s = l
l.p = k
l.s = a
c.p = j
c.z = j
c.o = d
assert d.z.s.s.s.w.w.w.s.txt == "g"