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

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

b = A("b")
l = B("l")
f = B("f")
n = A("n")

b.y = l
l.x = f
f.x = l
n.y = f
assert f.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

b = A("b")
l = B("l")
f = B("f")
n = A("n")

b.y = l
l.x = f
f.x = l
n.y = f
assert f.x.x.x.txt == "l"