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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

e.p = n
e.x = d
h.o = d
n.v = d
d.r = h
assert h.o.r.o.r.txt == "h"