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

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

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

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

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

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

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

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

k.u = g
n.s = k
g.u = k
g.t = k
assert k.u.t.u.txt == "g"