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

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

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

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

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

n.x = a
n.z = a
n.t = h
n.w = h
h.t = k
h.q = k
h.w = a
k.s = n
k.x = h
k.z = h
a.s = n
a.r = n
a.v = n
a.q = h
assert k.s.z.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: B = None
        self.z: D = None
        self.w: B = None
        self.txt = txt

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

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

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

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

n.x = a
n.z = a
n.t = h
n.w = h
h.t = k
h.q = k
h.w = a
k.s = n
k.x = h
k.z = h
a.s = n
a.r = n
a.v = n
a.q = h
assert k.s.z.v.x.txt == "a"