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

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

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

f.q = j
f.w = n
i.z = d
m.q = i
m.w = n
a.z = d
h.z = i
l.q = h
l.w = h
n.z = h
j.z = a
g.z = i
d.z = i
assert i.z.z.z.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: B = None
        self.txt = txt

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

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

f.q = j
f.w = n
i.z = d
m.q = i
m.w = n
a.z = d
h.z = i
l.q = h
l.w = h
n.z = h
j.z = a
g.z = i
d.z = i
assert i.z.z.z.z.z.z.z.z.z.z.txt == "i"