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

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

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

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

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

l = A("l")
d = B("d")
c = C("c")
f = D("f")
e = E("e")

l.u = c
l.z = f
l.y = f
l.w = d
d.u = l
d.t = f
c.x = l
f.z = l
f.t = l
f.q = e
e.x = c
e.y = c
e.z = d
assert d.u.w.u.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: D = None
        self.w: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

l = A("l")
d = B("d")
c = C("c")
f = D("f")
e = E("e")

l.u = c
l.z = f
l.y = f
l.w = d
d.u = l
d.t = f
c.x = l
f.z = l
f.t = l
f.q = e
e.x = c
e.y = c
e.z = d
assert d.u.w.u.w.t.txt == "f"