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

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

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

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

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

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

m.t = i
i.s = a
a.t = j
j.s = m
assert m.t.s.t.txt == "j"