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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.y: A = None
        self.x: B = None
        self.txt = txt

l = A("l")
h = B("h")
g = C("g")
e = D("e")
m = E("m")

l.u = m
h.y = l
h.w = l
h.t = e
g.y = l
e.z = m
e.x = h
m.u = g
m.w = g
m.y = l
m.x = h
assert l.u.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.y: A = None
        self.x: B = None
        self.txt = txt

l = A("l")
h = B("h")
g = C("g")
e = D("e")
m = E("m")

l.u = m
h.y = l
h.w = l
h.t = e
g.y = l
e.z = m
e.x = h
m.u = g
m.w = g
m.y = l
m.x = h
assert l.u.w.y.txt == "l"