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

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: D = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
m = C("m")
e = D("e")
i = E("i")

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

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: D = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
m = C("m")
e = D("e")
i = E("i")

a.x = i
f.u = a
f.p = e
m.p = a
m.y = a
m.u = e
m.x = e
e.x = m
e.w = f
e.s = i
i.p = e
i.t = f
assert e.w.u.x.p.w.txt == "f"