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

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

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

b = A("b")
a = B("a")
e = C("e")
c = A("c")

b.p = c
b.w = c
a.s = e
a.w = e
e.o = c
c.p = b
c.w = b
assert e.o.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.w: A = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
e = C("e")
c = A("c")

b.p = c
b.w = c
a.s = e
a.w = e
e.o = c
c.p = b
c.w = b
assert e.o.p.p.p.txt == "b"