class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: D = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
m = C("m")
h = D("h")
i = E("i")

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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.v: D = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
m = C("m")
h = D("h")
i = E("i")

a.t = g
g.x = h
g.v = h
m.w = a
h.o = m
h.s = m
h.u = m
h.x = g
h.q = i
i.r = h
i.u = h
assert i.r.q.u.x.x.txt == "h"