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

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

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

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

h.t = k
k.x = h
j.w = h
j.s = h
j.u = k
assert j.u.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

h.t = k
k.x = h
j.w = h
j.s = h
j.u = k
assert j.u.x.t.txt == "k"