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

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

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

g = A("g")
n = B("n")
i = C("i")
k = A("k")
m = A("m")
e = C("e")
c = B("c")
a = C("a")
h = C("h")
d = C("d")

g.x = k
g.s = k
n.w = c
n.v = a
i.v = h
i.q = g
k.x = m
k.s = g
m.x = g
m.s = k
e.v = i
e.q = k
c.w = n
c.v = e
a.v = d
a.q = k
h.v = d
h.q = k
d.v = a
d.q = k
assert d.v.v.v.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: A = None
        self.txt = txt

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

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

g = A("g")
n = B("n")
i = C("i")
k = A("k")
m = A("m")
e = C("e")
c = B("c")
a = C("a")
h = C("h")
d = C("d")

g.x = k
g.s = k
n.w = c
n.v = a
i.v = h
i.q = g
k.x = m
k.s = g
m.x = g
m.s = k
e.v = i
e.q = k
c.w = n
c.v = e
a.v = d
a.q = k
h.v = d
h.q = k
d.v = a
d.q = k
assert d.v.v.v.v.q.txt == "k"