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

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

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

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

k.w = m
h.z = b
b.v = m
b.q = i
g.w = n
n.w = g
i.v = n
i.q = b
m.w = k
assert i.v.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

k.w = m
h.z = b
b.v = m
b.q = i
g.w = n
n.w = g
i.v = n
i.q = b
m.w = k
assert i.v.w.w.w.w.txt == "n"