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

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

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

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

e.v = a
d.w = b
d.y = b
n.q = e
n.w = h
h.q = a
h.w = n
m.w = d
m.y = k
a.v = e
k.w = b
k.y = d
b.w = k
b.y = d
assert h.w.q.v.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.w: B = None
        self.y: B = None
        self.txt = txt

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

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

e.v = a
d.w = b
d.y = b
n.q = e
n.w = h
h.q = a
h.w = n
m.w = d
m.y = k
a.v = e
k.w = b
k.y = d
b.w = k
b.y = d
assert h.w.q.v.v.v.v.v.txt == "a"