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

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

f = A("f")
d = B("d")
k = A("k")

f.t = k
d.s = k
d.o = k
k.t = f
assert k.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

f = A("f")
d = B("d")
k = A("k")

f.t = k
d.s = k
d.o = k
k.t = f
assert k.t.t.t.txt == "f"