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

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

b = A("b")
l = B("l")
g = B("g")
f = B("f")
k = B("k")
e = A("e")

b.y = e
l.s = e
g.s = e
f.s = e
k.s = b
e.y = b
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.s: A = None
        self.txt = txt

b = A("b")
l = B("l")
g = B("g")
f = B("f")
k = B("k")
e = A("e")

b.y = e
l.s = e
g.s = e
f.s = e
k.s = b
e.y = b
assert e.y.y.y.txt == "b"