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

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

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

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

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

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

c.r = i
c.p = i
i.o = m
i.r = m
m.o = i
m.r = i
assert i.r.r.o.txt == "m"