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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: H = None
        self.r: D = None
        self.s: B = None
        self.x: A = None
        self.p: H = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: A = None
        self.t: C = None
        self.w: G = None
        self.u: E = None
        self.txt = txt

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

class H:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: E = None
        self.txt = txt

h = A("h")
n = B("n")
f = C("f")
g = D("g")
e = E("e")
c = F("c")
m = G("m")
a = H("a")

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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: G = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: H = None
        self.r: D = None
        self.s: B = None
        self.x: A = None
        self.p: H = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: A = None
        self.t: C = None
        self.w: G = None
        self.u: E = None
        self.txt = txt

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

class H:
    def __init__(self, txt: str):
        self.w: B = None
        self.t: E = None
        self.txt = txt

h = A("h")
n = B("n")
f = C("f")
g = D("g")
e = E("e")
c = F("c")
m = G("m")
a = H("a")

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