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

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

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

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

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

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

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

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

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

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

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

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

h.o = e
h.x = i
j.s = m
j.o = m
j.z = m
e.p = n
e.o = m
e.r = d
e.q = h
b.r = m
m.p = e
m.v = l
l.s = m
l.o = m
l.z = m
f.o = n
f.x = i
d.o = e
d.x = b
n.p = e
n.o = m
n.r = d
n.q = f
i.r = m
assert e.r.x.r.v.z.p.q.txt == "h"