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

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

l = A("l")
b = B("b")
d = B("d")
f = A("f")
e = A("e")
j = B("j")
a = B("a")

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

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

l = A("l")
b = B("b")
d = B("d")
f = A("f")
e = A("e")
j = B("j")
a = B("a")

l.y = j
l.w = b
b.z = f
b.w = e
d.z = e
d.w = f
f.y = j
f.w = d
e.y = b
e.w = a
j.z = f
j.w = f
a.z = f
a.w = l
assert f.w.z.w.z.txt == "f"