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

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

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

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

c.v = d
c.s = a
c.p = b
b.y = c
b.p = c
b.s = a
d.w = a
d.o = a
a.v = d
a.s = c
a.p = b
assert a.p.p.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: A = None
        self.p: B = None
        self.txt = txt

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

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

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

c.v = d
c.s = a
c.p = b
b.y = c
b.p = c
b.s = a
d.w = a
d.o = a
a.v = d
a.s = c
a.p = b
assert a.p.p.p.s.txt == "a"