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

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

c = A("c")
b = B("b")
i = B("i")
e = A("e")

c.p = i
c.o = i
b.o = i
b.p = c
i.o = b
i.p = c
e.p = i
e.o = i
assert c.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: B = None
        self.txt = txt

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

c = A("c")
b = B("b")
i = B("i")
e = A("e")

c.p = i
c.o = i
b.o = i
b.p = c
i.o = b
i.p = c
e.p = i
e.o = i
assert c.o.o.o.o.txt == "b"