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

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

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

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

i.r = n
h.w = i
h.z = i
h.u = n
n.t = f
n.x = i
f.t = n
f.x = i
assert h.u.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

i.r = n
h.w = i
h.z = i
h.u = n
n.t = f
n.x = i
f.t = n
f.x = i
assert h.u.t.x.txt == "i"