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

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

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

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

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

f = A("f")
a = B("a")
h = C("h")
b = D("b")
k = E("k")

f.z = a
f.r = a
f.o = b
f.x = k
a.r = k
a.z = k
h.s = b
b.y = h
k.s = f
k.x = f
k.o = b
k.z = b
k.q = h
assert h.s.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.o: D = None
        self.x: E = None
        self.txt = txt

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

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

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

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

f = A("f")
a = B("a")
h = C("h")
b = D("b")
k = E("k")

f.z = a
f.r = a
f.o = b
f.x = k
a.r = k
a.z = k
h.s = b
b.y = h
k.s = f
k.x = f
k.o = b
k.z = b
k.q = h
assert h.s.y.s.y.txt == "h"