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

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

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

n = A("n")
k = B("k")
c = C("c")
h = C("h")
j = A("j")

n.v = j
k.y = n
c.p = h
c.u = j
h.p = c
h.u = j
j.v = n
assert n.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
c = C("c")
h = C("h")
j = A("j")

n.v = j
k.y = n
c.p = h
c.u = j
h.p = c
h.u = j
j.v = n
assert n.v.v.v.v.txt == "n"