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

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

l = A("l")
i = B("i")
d = A("d")
c = B("c")
f = B("f")
h = B("h")

l.p = d
i.p = l
d.p = l
c.p = d
f.p = l
h.p = l
assert l.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

l = A("l")
i = B("i")
d = A("d")
c = B("c")
f = B("f")
h = B("h")

l.p = d
i.p = l
d.p = l
c.p = d
f.p = l
h.p = l
assert l.p.p.p.p.txt == "l"