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

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

j = A("j")
l = B("l")
i = B("i")

j.x = i
l.t = j
i.t = j
assert j.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

j = A("j")
l = B("l")
i = B("i")

j.x = i
l.t = j
i.t = j
assert j.x.t.x.txt == "i"