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

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

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

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

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

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

i.p = l
l.r = i
l.s = i
c.r = i
c.s = i
assert i.p.s.p.txt == "l"