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

class B:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

n = A("n")
c = B("c")
a = C("a")
h = D("h")
d = E("d")

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

class B:
    def __init__(self, txt: str):
        self.w: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

n = A("n")
c = B("c")
a = C("a")
h = D("h")
d = E("d")

n.z = a
n.t = h
n.q = h
c.w = d
a.s = h
a.r = d
a.v = d
h.v = a
d.s = n
assert c.w.s.q.txt == "h"