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

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

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

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

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

m = A("m")
k = B("k")
f = C("f")
j = D("j")
h = E("h")

m.u = j
m.o = j
m.r = j
m.w = f
m.q = f
k.w = m
k.t = m
k.o = j
k.v = f
f.q = k
j.s = h
h.s = f
h.o = f
assert h.s.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: C = None
        self.o: D = None
        self.r: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

m = A("m")
k = B("k")
f = C("f")
j = D("j")
h = E("h")

m.u = j
m.o = j
m.r = j
m.w = f
m.q = f
k.w = m
k.t = m
k.o = j
k.v = f
f.q = k
j.s = h
h.s = f
h.o = f
assert h.s.q.o.txt == "j"