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

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

a = A("a")
m = B("m")
i = B("i")
f = A("f")
b = B("b")
l = B("l")

a.z = l
a.y = m
m.w = l
m.z = l
i.w = m
i.z = b
f.z = b
f.y = b
b.w = i
b.z = i
l.w = b
l.z = b
assert l.z.z.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: B = None
        self.txt = txt

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

a = A("a")
m = B("m")
i = B("i")
f = A("f")
b = B("b")
l = B("l")

a.z = l
a.y = m
m.w = l
m.z = l
i.w = m
i.z = b
f.z = b
f.y = b
b.w = i
b.z = i
l.w = b
l.z = b
assert l.z.z.w.w.txt == "l"