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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: D = None
        self.s: A = None
        self.z: B = None
        self.txt = txt

m = A("m")
b = B("b")
l = C("l")
e = D("e")
n = E("n")
j = E("j")
g = A("g")
d = A("d")

m.r = l
m.y = g
m.x = g
m.o = e
b.s = m
b.p = g
l.o = n
l.w = b
e.x = j
n.r = e
n.y = e
n.s = m
n.z = b
j.r = e
j.y = e
j.s = m
j.z = b
g.r = l
g.y = d
g.o = e
g.x = m
d.r = l
d.y = g
d.o = e
d.x = m
assert n.z.s.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: A = None
        self.o: D = None
        self.x: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: D = None
        self.s: A = None
        self.z: B = None
        self.txt = txt

m = A("m")
b = B("b")
l = C("l")
e = D("e")
n = E("n")
j = E("j")
g = A("g")
d = A("d")

m.r = l
m.y = g
m.x = g
m.o = e
b.s = m
b.p = g
l.o = n
l.w = b
e.x = j
n.r = e
n.y = e
n.s = m
n.z = b
j.r = e
j.y = e
j.s = m
j.z = b
g.r = l
g.y = d
g.o = e
g.x = m
d.r = l
d.y = g
d.o = e
d.x = m
assert n.z.s.o.x.txt == "j"