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

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

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

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

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

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

g.q = d
k.v = a
c.v = d
f.v = g
l.v = d
n.v = d
i.v = d
d.q = g
a.q = d
j.q = d
assert l.v.q.q.q.q.q.q.q.q.q.txt == "g"