class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

a = A("a")
d = B("d")
e = C("e")
h = D("h")

a.p = e
a.r = h
d.v = e
e.y = h
h.p = e
h.s = e
h.y = e
assert h.s.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

a = A("a")
d = B("d")
e = C("e")
h = D("h")

a.p = e
a.r = h
d.v = e
e.y = h
h.p = e
h.s = e
h.y = e
assert h.s.y.p.txt == "e"