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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.o: E = None
        self.y: B = None
        self.s: A = None
        self.txt = txt

m = A("m")
g = B("g")
f = C("f")
j = D("j")
n = E("n")
c = B("c")
a = E("a")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.o: E = None
        self.y: B = None
        self.s: A = None
        self.txt = txt

m = A("m")
g = B("g")
f = C("f")
j = D("j")
n = E("n")
c = B("c")
a = E("a")

m.y = f
g.o = c
g.q = m
g.z = a
g.r = f
f.p = m
f.x = a
j.x = c
n.z = f
n.x = f
n.o = a
n.y = g
n.s = m
c.o = g
c.q = m
c.z = a
c.r = f
a.z = f
a.x = f
a.o = n
a.y = g
a.s = m
assert m.y.x.o.o.o.txt == "n"