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

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

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

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

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

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

m.o = j
c.p = j
j.p = c
assert m.o.p.p.txt == "j"