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

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

j = A("j")
i = B("i")
e = B("e")
l = B("l")
b = A("b")

j.q = e
i.u = j
i.x = e
e.u = j
e.x = i
l.u = j
l.x = e
b.q = e
assert i.u.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

j = A("j")
i = B("i")
e = B("e")
l = B("l")
b = A("b")

j.q = e
i.u = j
i.x = e
e.u = j
e.x = i
l.u = j
l.x = e
b.q = e
assert i.u.q.u.txt == "j"