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

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

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

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: A = None
        self.w: B = None
        self.v: C = None
        self.txt = txt

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

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

h.w = e
h.z = e
h.y = d
h.p = f
a.y = h
e.s = m
e.o = a
d.q = a
d.w = a
d.o = h
d.v = e
f.s = m
m.s = f
assert e.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: D = None
        self.z: C = None
        self.p: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.o: A = None
        self.w: B = None
        self.v: C = None
        self.txt = txt

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

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

h.w = e
h.z = e
h.y = d
h.p = f
a.y = h
e.s = m
e.o = a
d.q = a
d.w = a
d.o = h
d.v = e
f.s = m
m.s = f
assert e.s.s.s.s.s.s.txt == "f"