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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: H = None
        self.p: B = None
        self.v: B = None
        self.q: H = None
        self.t: H = None
        self.o: H = None
        self.r: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.q: G = None
        self.t: F = None
        self.s: B = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.z: A = None
        self.s: G = None
        self.x: F = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: H = None
        self.p: B = None
        self.v: B = None
        self.q: H = None
        self.t: H = None
        self.o: H = None
        self.r: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.q: G = None
        self.t: F = None
        self.s: B = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.z: A = None
        self.s: G = None
        self.x: F = None
        self.txt = txt

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

a.s = g
h.u = a
k.z = b
k.r = b
k.x = n
k.t = n
k.o = n
k.p = h
k.v = h
k.q = m
j.o = h
g.q = c
g.t = l
g.s = h
l.o = a
c.q = a
c.p = j
n.z = a
n.s = c
n.x = l
b.o = h
m.z = a
m.s = c
m.x = l
assert m.z.s.t.o.s.q.q.s.txt == "g"