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

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

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

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

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

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

m.u = h
m.r = d
h.o = a
h.t = a
h.w = m
h.u = m
h.x = f
a.o = d
a.s = f
f.q = m
f.v = h
f.z = h
f.r = h
d.y = f
d.s = m
assert h.t.o.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: E = None
        self.txt = txt

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

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

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

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

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

m.u = h
m.r = d
h.o = a
h.t = a
h.w = m
h.u = m
h.x = f
a.o = d
a.s = f
f.q = m
f.v = h
f.z = h
f.r = h
d.y = f
d.s = m
assert h.t.o.s.r.txt == "d"