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

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

n = A("n")
g = B("g")
a = B("a")
j = B("j")
d = B("d")
i = A("i")
c = A("c")
l = A("l")
h = B("h")

n.s = a
g.v = d
g.q = a
a.v = d
a.q = j
j.v = d
j.q = d
d.v = a
d.q = h
i.s = d
c.s = g
l.s = j
h.v = d
h.q = j
assert c.s.v.v.v.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

n = A("n")
g = B("g")
a = B("a")
j = B("j")
d = B("d")
i = A("i")
c = A("c")
l = A("l")
h = B("h")

n.s = a
g.v = d
g.q = a
a.v = d
a.q = j
j.v = d
j.q = d
d.v = a
d.q = h
i.s = d
c.s = g
l.s = j
h.v = d
h.q = j
assert c.s.v.v.v.q.q.txt == "j"