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

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

j = A("j")
b = B("b")
l = B("l")
k = A("k")
f = A("f")

j.s = b
b.q = j
l.q = k
k.s = l
f.s = b
assert j.s.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

j = A("j")
b = B("b")
l = B("l")
k = A("k")
f = A("f")

j.s = b
b.q = j
l.q = k
k.s = l
f.s = b
assert j.s.q.s.q.txt == "j"