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

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
e = C("e")
n = D("n")
h = E("h")

d.o = n
d.z = n
d.v = h
i.o = d
i.y = d
e.s = d
e.z = d
e.v = d
e.t = i
e.x = i
n.q = e
h.u = n
assert h.u.q.z.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.v: E = None
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
e = C("e")
n = D("n")
h = E("h")

d.o = n
d.z = n
d.v = h
i.o = d
i.y = d
e.s = d
e.z = d
e.v = d
e.t = i
e.x = i
n.q = e
h.u = n
assert h.u.q.z.o.q.txt == "e"