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

c = A("c")
h = B("h")
i = A("i")

c.p = i
h.o = i
i.p = c
assert c.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

c = A("c")
h = B("h")
i = A("i")

c.p = i
h.o = i
i.p = c
assert c.p.p.p.txt == "i"