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

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

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

h = A("h")
b = B("b")
n = C("n")

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

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

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

h = A("h")
b = B("b")
n = C("n")

h.r = n
h.v = n
h.z = n
b.w = h
n.t = b
n.x = h
assert b.w.v.t.txt == "b"