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

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

m = A("m")
k = B("k")
l = A("l")
i = A("i")
f = A("f")
g = A("g")
c = B("c")

m.q = f
k.t = c
k.z = m
l.q = g
i.q = g
f.q = l
g.q = i
c.t = k
c.z = m
assert i.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.t: B = None
        self.z: A = None
        self.txt = txt

m = A("m")
k = B("k")
l = A("l")
i = A("i")
f = A("f")
g = A("g")
c = B("c")

m.q = f
k.t = c
k.z = m
l.q = g
i.q = g
f.q = l
g.q = i
c.t = k
c.z = m
assert i.q.q.q.q.q.q.q.txt == "g"