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

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

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

j = A("j")
g = B("g")
m = C("m")
h = A("h")
l = C("l")
c = C("c")
n = C("n")
i = C("i")
f = A("f")
d = B("d")

j.q = h
g.z = j
g.y = d
m.v = c
h.q = j
l.v = c
c.v = i
n.v = l
i.v = c
f.q = h
d.z = j
d.y = g
assert j.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.z: A = None
        self.y: B = None
        self.txt = txt

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

j = A("j")
g = B("g")
m = C("m")
h = A("h")
l = C("l")
c = C("c")
n = C("n")
i = C("i")
f = A("f")
d = B("d")

j.q = h
g.z = j
g.y = d
m.v = c
h.q = j
l.v = c
c.v = i
n.v = l
i.v = c
f.q = h
d.z = j
d.y = g
assert j.q.q.q.q.q.q.txt == "j"