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

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

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

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

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

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

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

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

h.z = k
k.s = g
g.t = h
assert g.t.z.s.txt == "g"