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

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

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

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

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

i = A("i")
m = B("m")
n = C("n")
d = D("d")
g = E("g")
c = D("c")

i.r = n
i.u = g
i.z = m
m.w = c
m.r = i
m.q = g
n.s = g
d.p = n
d.o = g
g.t = i
c.p = n
c.o = g
assert c.o.t.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: E = None
        self.z: B = None
        self.txt = txt

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

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

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

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

i = A("i")
m = B("m")
n = C("n")
d = D("d")
g = E("g")
c = D("c")

i.r = n
i.u = g
i.z = m
m.w = c
m.r = i
m.q = g
n.s = g
d.p = n
d.o = g
g.t = i
c.p = n
c.o = g
assert c.o.t.z.w.txt == "c"