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

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

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

k = A("k")
m = B("m")
g = C("g")
j = A("j")
b = B("b")
h = A("h")
e = B("e")
a = A("a")
n = C("n")
d = A("d")

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

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

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

k = A("k")
m = B("m")
g = C("g")
j = A("j")
b = B("b")
h = A("h")
e = B("e")
a = A("a")
n = C("n")
d = A("d")

k.v = b
m.q = h
g.s = h
g.x = e
g.u = e
j.v = b
b.q = a
h.v = m
e.q = j
a.v = b
n.s = a
n.x = b
n.u = e
d.v = m
assert g.x.q.v.q.v.q.v.q.txt == "a"