class A:
    def __init__(self, txt: str):
        self.q: 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.v: C = None
        self.x: A = None
        self.y: B = None
        self.txt = txt

b = A("b")
j = B("j")
k = C("k")
a = C("a")
f = B("f")
m = B("m")
l = A("l")
h = B("h")
g = A("g")

b.q = m
j.q = l
k.v = a
k.x = g
k.y = f
a.v = k
a.x = b
a.y = f
f.q = l
m.q = g
l.q = j
h.q = l
g.q = h
assert h.q.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: 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.v: C = None
        self.x: A = None
        self.y: B = None
        self.txt = txt

b = A("b")
j = B("j")
k = C("k")
a = C("a")
f = B("f")
m = B("m")
l = A("l")
h = B("h")
g = A("g")

b.q = m
j.q = l
k.v = a
k.x = g
k.y = f
a.v = k
a.x = b
a.y = f
f.q = l
m.q = g
l.q = j
h.q = l
g.q = h
assert h.q.q.q.q.q.q.q.q.txt == "j"