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

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

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

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

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

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

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

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

n.u = k
m.q = e
m.v = k
b.z = h
k.u = n
e.u = k
h.q = k
h.v = n
assert n.u.u.u.u.txt == "n"