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

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

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

d.p = i
k.o = i
i.p = d
assert d.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

d.p = i
k.o = i
i.p = d
assert d.p.p.p.txt == "i"