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

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

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

j.s = i
j.t = i
f.r = e
e.r = f
i.s = j
i.t = j
assert i.s.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: A = None
        self.txt = txt

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

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

j.s = i
j.t = i
f.r = e
e.r = f
i.s = j
i.t = j
assert i.s.t.t.t.txt == "i"