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

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

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

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

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

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

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

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

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

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

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

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

h.u = a
h.p = a
h.v = a
h.o = m
m.q = h
m.w = a
a.x = e
a.t = f
e.y = h
e.s = m
e.x = m
e.p = f
f.u = a
assert m.w.t.u.x.y.txt == "h"