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

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

c = A("c")
f = B("f")
k = B("k")
n = B("n")

c.s = n
f.x = c
k.x = c
n.x = c
assert c.s.x.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

c = A("c")
f = B("f")
k = B("k")
n = B("n")

c.s = n
f.x = c
k.x = c
n.x = c
assert c.s.x.s.x.txt == "c"