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

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

j = A("j")
l = B("l")
e = B("e")
m = A("m")

j.z = m
j.s = e
l.t = e
l.q = e
e.t = l
e.q = l
m.z = j
m.s = l
assert l.q.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.s: B = None
        self.txt = txt

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

j = A("j")
l = B("l")
e = B("e")
m = A("m")

j.z = m
j.s = e
l.t = e
l.q = e
e.t = l
e.q = l
m.z = j
m.s = l
assert l.q.t.t.txt == "e"