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

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

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

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

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

a = A("a")
b = B("b")
m = C("m")
e = D("e")
c = E("c")

a.u = c
b.w = c
b.v = m
m.y = a
m.t = a
m.u = b
m.w = b
m.p = c
e.y = b
e.w = b
e.x = m
c.t = b
assert c.t.v.u.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

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

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

a = A("a")
b = B("b")
m = C("m")
e = D("e")
c = E("c")

a.u = c
b.w = c
b.v = m
m.y = a
m.t = a
m.u = b
m.w = b
m.p = c
e.y = b
e.w = b
e.x = m
c.t = b
assert c.t.v.u.w.t.txt == "b"