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

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

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

g = A("g")
e = B("e")
i = C("i")
f = B("f")
d = B("d")
k = C("k")
b = A("b")
n = B("n")
a = A("a")

g.v = k
e.t = n
e.v = k
i.s = k
i.q = k
f.t = d
f.v = i
d.t = f
d.v = k
k.s = i
k.q = i
b.v = k
n.t = d
n.v = k
a.v = i
assert g.v.q.s.q.q.q.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
i = C("i")
f = B("f")
d = B("d")
k = C("k")
b = A("b")
n = B("n")
a = A("a")

g.v = k
e.t = n
e.v = k
i.s = k
i.q = k
f.t = d
f.v = i
d.t = f
d.v = k
k.s = i
k.q = i
b.v = k
n.t = d
n.v = k
a.v = i
assert g.v.q.s.q.q.q.q.s.txt == "i"