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

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

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

c.p = h
i.s = c
h.p = l
l.p = c
assert c.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.s: A = None
        self.txt = txt

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

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