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

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

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

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

k = A("k")
i = B("i")
h = C("h")
c = D("c")
l = C("l")
e = C("e")

k.v = e
i.w = k
i.z = c
i.t = c
i.q = e
h.r = l
h.v = c
c.w = l
c.s = k
c.p = i
l.r = e
l.v = c
e.r = l
e.v = c
assert c.s.v.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
h = C("h")
c = D("c")
l = C("l")
e = C("e")

k.v = e
i.w = k
i.z = c
i.t = c
i.q = e
h.r = l
h.v = c
c.w = l
c.s = k
c.p = i
l.r = e
l.v = c
e.r = l
e.v = c
assert c.s.v.v.w.txt == "l"