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

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

h = A("h")
l = B("l")
e = B("e")
b = A("b")
j = A("j")
n = B("n")
d = B("d")
a = A("a")
f = A("f")
c = A("c")

h.z = n
h.s = j
l.s = e
l.w = h
e.s = l
e.w = b
b.z = e
b.s = c
j.z = l
j.s = f
n.s = l
n.w = f
d.s = e
d.w = a
a.z = e
a.s = h
f.z = l
f.s = c
c.z = n
c.s = j
assert b.s.s.s.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: A = None
        self.txt = txt

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

h = A("h")
l = B("l")
e = B("e")
b = A("b")
j = A("j")
n = B("n")
d = B("d")
a = A("a")
f = A("f")
c = A("c")

h.z = n
h.s = j
l.s = e
l.w = h
e.s = l
e.w = b
b.z = e
b.s = c
j.z = l
j.s = f
n.s = l
n.w = f
d.s = e
d.w = a
a.z = e
a.s = h
f.z = l
f.s = c
c.z = n
c.s = j
assert b.s.s.s.z.w.txt == "h"