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

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

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

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

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

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

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

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

g.w = h
g.z = f
h.t = f
h.u = g
f.r = h
f.t = g
f.v = g
assert g.z.r.u.txt == "g"