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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: I = None
        self.r: F = None
        self.q: H = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.o: B = None
        self.u: H = None
        self.p: I = None
        self.x: A = None
        self.z: I = None
        self.w: I = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.z: D = None
        self.u: E = None
        self.t: G = None
        self.s: C = None
        self.p: D = None
        self.w: I = None
        self.r: G = None
        self.o: A = None
        self.x: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.p: I = None
        self.txt = txt

class I:
    def __init__(self, txt: str):
        self.p: F = None
        self.r: C = None
        self.txt = txt

n = A("n")
m = B("m")
h = C("h")
d = D("d")
f = E("f")
j = F("j")
c = G("c")
g = H("g")
i = I("i")
a = G("a")

n.q = h
m.p = h
m.y = i
m.r = j
m.q = g
h.p = m
d.y = f
d.o = m
d.u = g
d.p = i
d.z = i
d.w = i
d.x = n
f.t = h
j.w = n
j.o = g
j.q = h
c.z = d
c.p = d
c.u = f
c.t = a
c.r = a
c.s = h
c.w = i
c.o = n
c.x = g
g.p = i
i.p = j
i.r = h
a.z = d
a.p = d
a.u = f
a.t = c
a.r = c
a.s = h
a.w = i
a.o = n
a.x = g
assert m.q.p.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: I = None
        self.r: F = None
        self.q: H = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.o: B = None
        self.u: H = None
        self.p: I = None
        self.x: A = None
        self.z: I = None
        self.w: I = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.z: D = None
        self.u: E = None
        self.t: G = None
        self.s: C = None
        self.p: D = None
        self.w: I = None
        self.r: G = None
        self.o: A = None
        self.x: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.p: I = None
        self.txt = txt

class I:
    def __init__(self, txt: str):
        self.p: F = None
        self.r: C = None
        self.txt = txt

n = A("n")
m = B("m")
h = C("h")
d = D("d")
f = E("f")
j = F("j")
c = G("c")
g = H("g")
i = I("i")
a = G("a")

n.q = h
m.p = h
m.y = i
m.r = j
m.q = g
h.p = m
d.y = f
d.o = m
d.u = g
d.p = i
d.z = i
d.w = i
d.x = n
f.t = h
j.w = n
j.o = g
j.q = h
c.z = d
c.p = d
c.u = f
c.t = a
c.r = a
c.s = h
c.w = i
c.o = n
c.x = g
g.p = i
i.p = j
i.r = h
a.z = d
a.p = d
a.u = f
a.t = c
a.r = c
a.s = h
a.w = i
a.o = n
a.x = g
assert m.q.p.p.q.txt == "h"