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

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

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

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

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

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

j.w = e
e.y = j
e.z = j
a.y = j
a.z = j
assert j.w.y.w.txt == "e"