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

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

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

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

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

d.x = f
d.v = i
f.p = e
f.r = a
h.x = f
i.s = d
i.z = h
i.v = a
i.t = f
e.s = d
e.z = h
e.v = a
e.t = f
j.x = f
j.v = e
a.s = j
a.z = h
a.v = i
a.t = f
assert e.z.x.r.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: D = None
        self.txt = txt

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

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

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

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

d.x = f
d.v = i
f.p = e
f.r = a
h.x = f
i.s = d
i.z = h
i.v = a
i.t = f
e.s = d
e.z = h
e.v = a
e.t = f
j.x = f
j.v = e
a.s = j
a.z = h
a.v = i
a.t = f
assert e.z.x.r.t.p.txt == "e"