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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.x: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

h.u = i
h.s = m
n.v = m
n.o = h
n.w = e
n.p = i
i.w = m
i.x = e
e.q = i
e.x = i
m.x = i
assert e.q.w.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.x: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

h.u = i
h.s = m
n.v = m
n.o = h
n.w = e
n.p = i
i.w = m
i.x = e
e.q = i
e.x = i
m.x = i
assert e.q.w.x.x.txt == "e"