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

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

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

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

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

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

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

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

h.u = k
h.z = k
h.r = k
k.y = h
k.z = h
k.v = g
g.t = k
g.r = k
assert k.y.r.y.txt == "h"