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

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

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

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

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

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

d.o = j
j.s = k
k.s = j
assert d.o.s.s.txt == "j"