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

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

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

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

f.z = g
m.q = h
a.q = h
a.y = l
a.v = g
i.q = m
i.y = l
i.v = f
h.q = m
j.z = f
l.q = m
l.y = a
l.v = f
c.q = m
g.z = f
assert h.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

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