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

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

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

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

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

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

b.y = e
l.q = i
i.y = l
e.q = m
m.y = l
assert l.q.y.q.txt == "i"