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

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

c = A("c")
f = B("f")
i = B("i")
a = A("a")
e = B("e")

c.y = a
f.x = e
f.s = e
i.x = f
i.s = e
a.y = c
e.x = f
e.s = f
assert a.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.x: B = None
        self.s: B = None
        self.txt = txt

c = A("c")
f = B("f")
i = B("i")
a = A("a")
e = B("e")

c.y = a
f.x = e
f.s = e
i.x = f
i.s = e
a.y = c
e.x = f
e.s = f
assert a.y.y.y.txt == "c"