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

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

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

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

f.w = n
g.z = b
h.r = n
i.r = n
k.w = f
n.w = k
b.z = g
assert f.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: B = None
        self.txt = txt

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

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

f.w = n
g.z = b
h.r = n
i.r = n
k.w = f
n.w = k
b.z = g
assert f.w.w.w.w.txt == "n"