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

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

j = A("j")
f = B("f")
l = B("l")

j.z = l
f.p = l
l.p = f
assert l.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

j = A("j")
f = B("f")
l = B("l")

j.z = l
f.p = l
l.p = f
assert l.p.p.p.txt == "f"