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

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

n = A("n")
f = B("f")
e = A("e")
j = B("j")
g = A("g")
k = A("k")
d = B("d")
h = A("h")
c = B("c")

n.w = j
f.x = h
f.z = h
e.w = d
j.x = k
j.z = h
g.w = c
k.w = j
d.x = k
d.z = h
h.w = d
c.x = e
c.z = k
assert j.z.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

n = A("n")
f = B("f")
e = A("e")
j = B("j")
g = A("g")
k = A("k")
d = B("d")
h = A("h")
c = B("c")

n.w = j
f.x = h
f.z = h
e.w = d
j.x = k
j.z = h
g.w = c
k.w = j
d.x = k
d.z = h
h.w = d
c.x = e
c.z = k
assert j.z.w.z.txt == "h"