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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

i.q = k
i.z = a
k.y = m
k.w = g
d.u = k
d.r = g
d.t = m
m.y = g
m.u = d
g.y = a
a.q = k
a.z = i
assert i.z.z.z.z.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: A = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

i.q = k
i.z = a
k.y = m
k.w = g
d.u = k
d.r = g
d.t = m
m.y = g
m.u = d
g.y = a
a.q = k
a.z = i
assert i.z.z.z.z.q.w.txt == "g"