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

class B:
    def __init__(self, txt: str):
        self.q: G = None
        self.t: G = None
        self.x: G = None
        self.r: F = None
        self.y: C = None
        self.w: F = None
        self.v: C = None
        self.txt = txt

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

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: E = None
        self.z: A = None
        self.o: C = None
        self.v: B = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.q: G = None
        self.t: G = None
        self.x: G = None
        self.r: F = None
        self.y: C = None
        self.w: F = None
        self.v: C = None
        self.txt = txt

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

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: E = None
        self.z: A = None
        self.o: C = None
        self.v: B = None
        self.txt = txt

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

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