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

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

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

f = A("f")
h = B("h")
d = C("d")

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

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

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

f = A("f")
h = B("h")
d = C("d")

f.x = d
h.y = f
d.t = h
assert h.y.x.t.txt == "h"