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

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

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

h = A("h")
b = B("b")
m = C("m")
i = A("i")
j = A("j")

h.t = b
h.z = b
b.x = j
b.r = i
m.z = h
m.s = h
m.v = b
i.t = b
i.z = b
j.t = b
j.z = b
assert m.v.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: B = None
        self.txt = txt

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

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

h = A("h")
b = B("b")
m = C("m")
i = A("i")
j = A("j")

h.t = b
h.z = b
b.x = j
b.r = i
m.z = h
m.s = h
m.v = b
i.t = b
i.z = b
j.t = b
j.z = b
assert m.v.r.t.r.txt == "i"