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

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

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

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

f.z = h
h.t = i
h.w = f
i.r = h
i.o = f
i.q = f
assert i.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

f.z = h
h.t = i
h.w = f
i.r = h
i.o = f
i.q = f
assert i.r.t.r.txt == "h"