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

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

l = A("l")
c = B("c")
m = A("m")
h = A("h")
e = A("e")
j = B("j")
f = B("f")
g = A("g")
d = B("d")
i = A("i")

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

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

l = A("l")
c = B("c")
m = A("m")
h = A("h")
e = A("e")
j = B("j")
f = B("f")
g = A("g")
d = B("d")
i = A("i")

l.w = g
l.z = d
c.x = i
c.v = g
m.w = g
m.z = j
h.w = e
h.z = c
e.w = g
e.z = j
j.x = h
j.v = l
f.x = g
f.v = h
g.w = h
g.z = d
d.x = m
d.v = i
i.w = m
i.z = d
assert f.v.w.z.txt == "j"