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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: A = None
        self.o: A = None
        self.r: D = None
        self.y: C = None
        self.txt = txt

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

a.w = f
e.q = f
e.z = f
e.y = c
e.t = a
f.u = c
b.x = f
c.q = e
c.z = a
c.o = a
c.r = b
c.y = f
assert c.r.x.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: A = None
        self.o: A = None
        self.r: D = None
        self.y: C = None
        self.txt = txt

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

a.w = f
e.q = f
e.z = f
e.y = c
e.t = a
f.u = c
b.x = f
c.q = e
c.z = a
c.o = a
c.r = b
c.y = f
assert c.r.x.u.y.txt == "f"