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.w: B = None
        self.txt = txt

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

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

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

c.p = l
h.s = l
h.w = k
l.p = c
k.s = l
k.w = h
assert h.w.s.p.txt == "c"