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

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

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

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

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

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

j.q = g
j.s = i
l.q = f
g.q = l
f.q = g
k.q = c
c.q = g
i.q = l
i.s = j
m.q = g
n.q = c
n.s = d
d.q = k
d.s = n
assert f.q.q.q.q.q.txt == "l"