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

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

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

e = A("e")
f = B("f")
g = C("g")
n = A("n")
k = B("k")

e.s = k
f.o = n
g.r = e
n.s = f
k.o = e
assert g.r.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
g = C("g")
n = A("n")
k = B("k")

e.s = k
f.o = n
g.r = e
n.s = f
k.o = e
assert g.r.s.o.txt == "e"