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

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

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

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

a = A("a")
h = B("h")
n = C("n")
k = D("k")
f = D("f")
b = D("b")
d = B("d")

a.z = h
a.t = f
a.s = f
a.y = d
h.s = b
h.v = n
n.r = h
k.v = a
k.z = d
f.v = a
f.z = d
b.v = a
b.z = h
d.s = f
d.v = n
assert a.s.v.s.z.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: D = None
        self.y: B = None
        self.s: D = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
n = C("n")
k = D("k")
f = D("f")
b = D("b")
d = B("d")

a.z = h
a.t = f
a.s = f
a.y = d
h.s = b
h.v = n
n.r = h
k.v = a
k.z = d
f.v = a
f.z = d
b.v = a
b.z = h
d.s = f
d.v = n
assert a.s.v.s.z.s.v.s.txt == "f"