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

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

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

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

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

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

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

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

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

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

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

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

a.q = c
a.o = c
i.x = m
i.r = c
i.q = d
i.o = d
i.u = b
g.q = b
g.t = b
g.r = c
b.o = m
b.t = i
b.s = i
b.z = d
c.w = a
d.x = a
d.r = c
d.q = i
d.o = i
d.u = b
m.q = c
m.o = c
assert d.r.w.o.w.txt == "a"