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

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

j = A("j")
f = B("f")
e = B("e")

j.x = f
f.w = e
e.w = f
assert f.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

j = A("j")
f = B("f")
e = B("e")

j.x = f
f.w = e
e.w = f
assert f.w.w.w.txt == "e"