class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: E = None
        self.p: E = None
        self.u: B = None
        self.y: C = None
        self.txt = txt

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

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

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

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

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

a.q = m
a.y = m
a.x = b
a.p = b
a.u = k
k.x = m
m.t = a
c.u = m
c.q = m
c.o = m
c.s = a
c.w = k
i.p = a
i.w = m
h.q = m
h.y = m
h.x = i
h.p = b
h.u = k
b.p = a
b.w = m
assert a.u.x.t.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: E = None
        self.p: E = None
        self.u: B = None
        self.y: C = None
        self.txt = txt

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

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

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

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

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

a.q = m
a.y = m
a.x = b
a.p = b
a.u = k
k.x = m
m.t = a
c.u = m
c.q = m
c.o = m
c.s = a
c.w = k
i.p = a
i.w = m
h.q = m
h.y = m
h.x = i
h.p = b
h.u = k
b.p = a
b.w = m
assert a.u.x.t.u.x.txt == "m"