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

f = A("f")
l = B("l")
c = B("c")
n = B("n")
m = B("m")
i = B("i")
d = A("d")
g = B("g")

f.y = d
l.s = d
c.s = f
n.s = f
m.s = d
i.s = f
d.y = f
g.s = d
assert d.y.y.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.s: A = None
        self.txt = txt

f = A("f")
l = B("l")
c = B("c")
n = B("n")
m = B("m")
i = B("i")
d = A("d")
g = B("g")

f.y = d
l.s = d
c.s = f
n.s = f
m.s = d
i.s = f
d.y = f
g.s = d
assert d.y.y.y.y.y.y.y.txt == "f"