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

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

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

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

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

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

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

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

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