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

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

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

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

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

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

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

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

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