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

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

f = A("f")
l = B("l")
i = B("i")
e = A("e")
g = B("g")
b = B("b")

f.z = l
l.v = f
l.w = i
i.v = e
i.w = l
e.z = b
g.v = f
g.w = l
b.v = f
b.w = l
assert e.z.w.v.z.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

f = A("f")
l = B("l")
i = B("i")
e = A("e")
g = B("g")
b = B("b")

f.z = l
l.v = f
l.w = i
i.v = e
i.w = l
e.z = b
g.v = f
g.w = l
b.v = f
b.w = l
assert e.z.w.v.z.v.z.txt == "l"