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

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

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

j.y = f
i.o = e
e.o = i
f.y = b
b.y = f
assert b.y.y.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.o: B = None
        self.txt = txt

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

j.y = f
i.o = e
e.o = i
f.y = b
b.y = f
assert b.y.y.y.y.y.txt == "f"