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

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

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

k = A("k")
g = B("g")
a = C("a")

k.s = g
k.w = g
g.r = a
a.s = k
a.v = g
a.o = g
assert g.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: B = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
a = C("a")

k.s = g
k.w = g
g.r = a
a.s = k
a.v = g
a.o = g
assert g.r.o.r.txt == "a"