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

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

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

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

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

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

a.w = d
a.p = d
d.z = j
d.s = h
k.w = j
k.p = d
j.z = d
j.s = d
h.z = j
h.s = j
g.w = d
g.p = h
m.w = j
m.p = h
l.w = d
l.p = h
f.w = h
f.p = j
n.w = h
n.p = j
assert n.w.s.s.s.s.s.z.s.z.txt == "j"