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

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: C = None
        self.o: D = None
        self.s: A = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.w: D = None
        self.s: E = None
        self.u: E = None
        self.r: C = None
        self.txt = txt

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

m.r = n
m.o = g
g.u = d
g.q = m
n.o = m
b.v = n
b.p = n
b.t = e
b.o = i
b.s = m
j.x = m
j.w = i
j.s = l
j.u = l
j.r = e
h.x = m
h.w = b
h.s = l
h.u = j
h.r = n
i.v = e
i.p = e
i.t = n
i.o = b
i.s = m
l.x = m
l.w = i
l.s = h
l.u = j
l.r = e
d.u = g
d.q = m
e.o = m
assert l.s.r.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: C = None
        self.o: D = None
        self.s: A = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.w: D = None
        self.s: E = None
        self.u: E = None
        self.r: C = None
        self.txt = txt

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

m.r = n
m.o = g
g.u = d
g.q = m
n.o = m
b.v = n
b.p = n
b.t = e
b.o = i
b.s = m
j.x = m
j.w = i
j.s = l
j.u = l
j.r = e
h.x = m
h.w = b
h.s = l
h.u = j
h.r = n
i.v = e
i.p = e
i.t = n
i.o = b
i.s = m
l.x = m
l.w = i
l.s = h
l.u = j
l.r = e
d.u = g
d.q = m
e.o = m
assert l.s.r.o.r.o.txt == "m"