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

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

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

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

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

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

e.o = g
e.q = m
e.s = c
a.y = m
c.z = e
c.r = m
c.x = a
m.x = e
g.r = m
g.o = a
assert m.x.o.r.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

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

e.o = g
e.q = m
e.s = c
a.y = m
c.z = e
c.r = m
c.x = a
m.x = e
g.r = m
g.o = a
assert m.x.o.r.x.q.txt == "m"