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

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

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

k = A("k")
b = B("b")
m = C("m")
n = A("n")
a = B("a")
h = C("h")

k.y = h
k.u = n
k.z = a
b.v = a
m.v = h
m.u = n
n.y = m
n.u = k
n.z = b
a.v = b
h.v = m
h.u = k
assert a.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.u: A = None
        self.z: B = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
m = C("m")
n = A("n")
a = B("a")
h = C("h")

k.y = h
k.u = n
k.z = a
b.v = a
m.v = h
m.u = n
n.y = m
n.u = k
n.z = b
a.v = b
h.v = m
h.u = k
assert a.v.v.v.v.txt == "a"