class A:
    def __init__(self, txt: str):
        self.y: C = 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: A = None
        self.txt = txt

f = A("f")
a = B("a")
n = C("n")
k = B("k")
h = A("h")
e = A("e")

f.y = n
a.v = k
n.v = f
k.v = a
h.y = n
e.y = n
assert n.v.y.v.y.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = 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: A = None
        self.txt = txt

f = A("f")
a = B("a")
n = C("n")
k = B("k")
h = A("h")
e = A("e")

f.y = n
a.v = k
n.v = f
k.v = a
h.y = n
e.y = n
assert n.v.y.v.y.v.y.txt == "n"