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

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

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

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

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

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

h.q = d
h.r = k
e.s = i
e.r = i
e.z = g
e.q = g
g.o = b
g.y = h
g.x = a
m.s = i
d.x = k
d.y = b
b.o = g
b.y = h
b.x = a
k.s = e
i.s = e
i.r = e
i.z = g
i.q = b
a.x = m
a.y = b
j.x = m
j.y = b
assert e.r.z.y.r.s.r.q.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

h.q = d
h.r = k
e.s = i
e.r = i
e.z = g
e.q = g
g.o = b
g.y = h
g.x = a
m.s = i
d.x = k
d.y = b
b.o = g
b.y = h
b.x = a
k.s = e
i.s = e
i.r = e
i.z = g
i.q = b
a.x = m
a.y = b
j.x = m
j.y = b
assert e.r.z.y.r.s.r.q.o.y.txt == "h"