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

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

j = A("j")
a = B("a")
b = A("b")
c = B("c")
h = B("h")
n = A("n")
i = A("i")

j.w = b
j.u = i
a.s = h
a.z = j
b.w = i
b.u = n
c.s = a
c.z = n
h.s = c
h.z = i
n.w = i
n.u = b
i.w = n
i.u = j
assert a.z.u.w.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.txt = txt

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

j = A("j")
a = B("a")
b = A("b")
c = B("c")
h = B("h")
n = A("n")
i = A("i")

j.w = b
j.u = i
a.s = h
a.z = j
b.w = i
b.u = n
c.s = a
c.z = n
h.s = c
h.z = i
n.w = i
n.u = b
i.w = n
i.u = j
assert a.z.u.w.w.u.w.txt == "b"