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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: E = None
        self.u: B = None
        self.w: B = None
        self.p: C = None
        self.x: C = None
        self.txt = txt

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

c.u = g
c.t = h
c.x = h
c.r = k
g.q = k
g.w = m
g.r = c
h.t = k
k.r = a
m.z = i
m.u = g
m.w = g
m.p = h
m.x = a
a.t = k
i.z = m
i.u = g
i.w = g
i.p = a
i.x = h
assert h.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: C = None
        self.r: D = None
        self.x: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: E = None
        self.u: B = None
        self.w: B = None
        self.p: C = None
        self.x: C = None
        self.txt = txt

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

c.u = g
c.t = h
c.x = h
c.r = k
g.q = k
g.w = m
g.r = c
h.t = k
k.r = a
m.z = i
m.u = g
m.w = g
m.p = h
m.x = a
a.t = k
i.z = m
i.u = g
i.w = g
i.p = a
i.x = h
assert h.t.r.t.r.txt == "a"