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

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

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

m = A("m")
g = B("g")
c = C("c")
k = A("k")

m.s = k
g.v = c
g.t = c
c.w = k
k.s = m
assert c.w.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
c = C("c")
k = A("k")

m.s = k
g.v = c
g.t = c
c.w = k
k.s = m
assert c.w.s.s.s.txt == "m"