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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: C = None
        self.o: E = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: C = None
        self.o: E = None
        self.txt = txt

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

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

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

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

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