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

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: C = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: C = None
        self.txt = txt

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

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

h.r = c
h.z = a
h.o = a
h.y = a
b.u = c
c.s = f
c.p = f
c.w = a
f.r = a
f.q = c
a.z = h
a.y = c
assert h.r.w.z.y.z.txt == "h"