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

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

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

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

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

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

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