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

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

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

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

h.t = i
h.y = a
a.x = i
i.y = a
assert h.y.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.y: B = None
        self.txt = txt

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

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

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

h.t = i
h.y = a
a.x = i
i.y = a
assert h.y.x.y.txt == "a"