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

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

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

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

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

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

e.y = j
l.y = j
m.y = j
j.y = e
assert e.y.y.y.txt == "j"