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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: G = None
        self.txt = txt

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

class H:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: G = None
        self.u: D = None
        self.txt = txt

a = A("a")
m = B("m")
l = C("l")
h = D("h")
k = E("k")
f = F("f")
c = G("c")
d = H("d")
b = G("b")
n = E("n")

a.r = m
a.q = m
a.u = k
a.t = h
m.y = a
l.s = a
l.y = a
h.o = n
k.z = d
k.r = f
k.o = m
f.x = l
f.u = c
c.u = a
c.s = a
c.q = m
c.x = m
d.q = f
d.v = b
d.u = h
b.u = a
b.s = a
b.q = m
b.x = m
n.z = d
n.r = f
n.o = m
assert n.o.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: B = None
        self.u: E = None
        self.t: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: G = None
        self.txt = txt

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

class H:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: G = None
        self.u: D = None
        self.txt = txt

a = A("a")
m = B("m")
l = C("l")
h = D("h")
k = E("k")
f = F("f")
c = G("c")
d = H("d")
b = G("b")
n = E("n")

a.r = m
a.q = m
a.u = k
a.t = h
m.y = a
l.s = a
l.y = a
h.o = n
k.z = d
k.r = f
k.o = m
f.x = l
f.u = c
c.u = a
c.s = a
c.q = m
c.x = m
d.q = f
d.v = b
d.u = h
b.u = a
b.s = a
b.q = m
b.x = m
n.z = d
n.r = f
n.o = m
assert n.o.y.r.txt == "m"