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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.r: A = None
        self.o: G = None
        self.y: F = None
        self.w: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: F = None
        self.z: G = None
        self.txt = txt

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: C = None
        self.z: E = None
        self.r: G = None
        self.txt = txt

h = A("h")
d = B("d")
i = C("i")
l = D("l")
g = E("g")
e = F("e")
b = G("b")
m = H("m")
a = D("a")
c = F("c")

h.q = m
h.p = i
h.u = b
h.o = e
d.t = l
d.r = h
d.o = b
d.y = e
d.w = e
i.o = a
i.s = e
i.z = b
l.p = a
l.y = a
l.w = h
g.t = b
g.z = i
e.r = h
e.w = h
e.u = d
b.y = d
b.z = a
m.t = g
m.z = g
m.p = i
m.r = b
a.p = l
a.y = l
a.w = h
c.r = h
c.w = h
c.u = d
assert b.y.w.r.q.r.y.w.r.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: H = None
        self.p: C = None
        self.u: G = None
        self.o: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.r: A = None
        self.o: G = None
        self.y: F = None
        self.w: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: F = None
        self.z: G = None
        self.txt = txt

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: C = None
        self.z: E = None
        self.r: G = None
        self.txt = txt

h = A("h")
d = B("d")
i = C("i")
l = D("l")
g = E("g")
e = F("e")
b = G("b")
m = H("m")
a = D("a")
c = F("c")

h.q = m
h.p = i
h.u = b
h.o = e
d.t = l
d.r = h
d.o = b
d.y = e
d.w = e
i.o = a
i.s = e
i.z = b
l.p = a
l.y = a
l.w = h
g.t = b
g.z = i
e.r = h
e.w = h
e.u = d
b.y = d
b.z = a
m.t = g
m.z = g
m.p = i
m.r = b
a.p = l
a.y = l
a.w = h
c.r = h
c.w = h
c.u = d
assert b.y.w.r.q.r.y.w.r.q.z.txt == "g"