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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.o: C = None
        self.u: C = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.o: C = None
        self.u: C = None
        self.txt = txt

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

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

a.p = d
a.y = b
a.z = b
b.v = e
b.o = e
b.u = e
e.w = d
e.v = b
d.p = a
d.y = b
d.z = b
assert e.v.v.v.v.txt == "e"