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

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

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

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

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

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

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

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

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

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

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

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

m.q = g
m.o = d
m.r = j
m.s = c
g.p = m
g.v = m
c.z = n
c.x = m
c.o = k
a.q = g
k.r = m
k.q = e
f.q = g
d.p = m
d.v = m
n.z = c
n.x = m
n.o = k
e.q = g
j.q = d
assert m.q.v.r.q.v.o.p.o.p.txt == "m"