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

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

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

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

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

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

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

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

c.s = k
k.u = g
g.u = c
assert k.u.u.s.txt == "k"