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

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

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

k = A("k")
e = B("e")
a = C("a")
i = C("i")
h = C("h")
d = C("d")
n = A("n")
c = A("c")
m = C("m")

k.w = c
e.q = c
e.w = d
a.v = n
i.v = n
h.v = k
d.v = c
n.w = k
c.w = n
m.v = n
assert h.v.w.w.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.q: A = None
        self.w: C = None
        self.txt = txt

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

k = A("k")
e = B("e")
a = C("a")
i = C("i")
h = C("h")
d = C("d")
n = A("n")
c = A("c")
m = C("m")

k.w = c
e.q = c
e.w = d
a.v = n
i.v = n
h.v = k
d.v = c
n.w = k
c.w = n
m.v = n
assert h.v.w.w.w.w.w.w.txt == "k"