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

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

j = A("j")
l = B("l")
a = A("a")
h = B("h")
n = B("n")

j.w = a
l.w = a
a.w = j
h.w = a
n.w = j
assert l.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

j = A("j")
l = B("l")
a = A("a")
h = B("h")
n = B("n")

j.w = a
l.w = a
a.w = j
h.w = a
n.w = j
assert l.w.w.w.txt == "a"