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

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

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

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

k = A("k")
n = B("n")
d = C("d")
m = D("m")
l = D("l")
g = C("g")
h = D("h")

k.z = n
k.p = d
n.z = d
n.v = d
n.t = d
n.y = k
d.s = g
d.v = g
m.u = l
l.u = m
g.s = d
g.v = d
h.u = l
assert d.v.s.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: C = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
d = C("d")
m = D("m")
l = D("l")
g = C("g")
h = D("h")

k.z = n
k.p = d
n.z = d
n.v = d
n.t = d
n.y = k
d.s = g
d.v = g
m.u = l
l.u = m
g.s = d
g.v = d
h.u = l
assert d.v.s.s.v.txt == "d"