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

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

j = A("j")
l = B("l")
c = A("c")
n = B("n")
f = A("f")
g = A("g")
a = B("a")
m = A("m")

j.q = l
l.t = f
c.q = n
n.t = m
f.q = a
g.q = n
a.t = f
m.q = l
assert c.q.t.q.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

j = A("j")
l = B("l")
c = A("c")
n = B("n")
f = A("f")
g = A("g")
a = B("a")
m = A("m")

j.q = l
l.t = f
c.q = n
n.t = m
f.q = a
g.q = n
a.t = f
m.q = l
assert c.q.t.q.t.q.t.txt == "f"