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

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

f = A("f")
d = B("d")
k = B("k")
j = B("j")
a = B("a")

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

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

f = A("f")
d = B("d")
k = B("k")
j = B("j")
a = B("a")

f.y = d
d.w = f
k.w = f
j.w = f
a.w = f
assert j.w.y.w.txt == "f"