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

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

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

a = A("a")
k = B("k")
h = C("h")
i = B("i")

a.v = i
k.t = h
h.s = k
h.y = k
h.w = a
i.t = h
assert i.t.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
h = C("h")
i = B("i")

a.v = i
k.t = h
h.s = k
h.y = k
h.w = a
i.t = h
assert i.t.s.t.s.txt == "k"