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

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

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

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

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

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

g.q = m
g.x = d
g.s = a
m.q = a
m.w = a
d.u = a
d.o = e
a.r = g
e.t = d
e.x = d
e.z = g
e.u = g
e.v = m
assert d.u.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.s: D = None
        self.txt = txt

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

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

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

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

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

g.q = m
g.x = d
g.s = a
m.q = a
m.w = a
d.u = a
d.o = e
a.r = g
e.t = d
e.x = d
e.z = g
e.u = g
e.v = m
assert d.u.r.s.txt == "a"