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

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

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

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

f.o = h
f.z = h
i.r = f
h.r = a
h.t = g
h.y = f
a.r = f
g.r = f
assert g.r.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: C = None
        self.txt = txt

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

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

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

f.o = h
f.z = h
i.r = f
h.r = a
h.t = g
h.y = f
a.r = f
g.r = f
assert g.r.o.y.txt == "f"