class A:
    def __init__(self, txt: str):
        self.z: B = 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.y: A = None
        self.x: D = None
        self.p: E = None
        self.v: A = None
        self.o: A = None
        self.txt = txt

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

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

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

b.z = d
d.y = b
f.y = b
f.v = b
f.o = b
f.x = k
f.p = a
k.w = b
k.u = f
a.s = b
a.z = b
a.r = d
a.q = k
assert f.p.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = 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.y: A = None
        self.x: D = None
        self.p: E = None
        self.v: A = None
        self.o: A = None
        self.txt = txt

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

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

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

b.z = d
d.y = b
f.y = b
f.v = b
f.o = b
f.x = k
f.p = a
k.w = b
k.u = f
a.s = b
a.z = b
a.r = d
a.q = k
assert f.p.s.z.txt == "d"