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

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

j = A("j")
k = B("k")
i = B("i")
a = A("a")

j.x = a
k.y = a
i.y = j
a.x = j
assert j.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

j = A("j")
k = B("k")
i = B("i")
a = A("a")

j.x = a
k.y = a
i.y = j
a.x = j
assert j.x.x.x.x.txt == "j"