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.z: B = None
        self.v: A = None
        self.txt = txt

g = A("g")
f = B("f")
b = A("b")
m = A("m")
d = B("d")
l = A("l")

g.w = b
g.z = d
f.z = d
f.v = b
b.w = l
b.z = d
m.w = g
m.z = d
d.z = f
d.v = m
l.w = g
l.z = f
assert g.z.v.w.z.z.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.z: B = None
        self.v: A = None
        self.txt = txt

g = A("g")
f = B("f")
b = A("b")
m = A("m")
d = B("d")
l = A("l")

g.w = b
g.z = d
f.z = d
f.v = b
b.w = l
b.z = d
m.w = g
m.z = d
d.z = f
d.v = m
l.w = g
l.z = f
assert g.z.v.w.z.z.z.txt == "d"