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

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

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

l = A("l")
d = B("d")
a = C("a")
b = A("b")
c = B("c")
n = B("n")
m = C("m")
h = C("h")

l.v = h
l.w = n
l.s = m
d.w = m
d.q = n
a.y = l
a.x = d
b.v = h
b.w = n
b.s = m
c.w = m
c.q = n
n.w = h
n.q = d
m.y = l
m.x = d
h.y = b
h.x = d
assert d.q.w.y.w.w.y.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: B = None
        self.s: C = None
        self.txt = txt

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

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

l = A("l")
d = B("d")
a = C("a")
b = A("b")
c = B("c")
n = B("n")
m = C("m")
h = C("h")

l.v = h
l.w = n
l.s = m
d.w = m
d.q = n
a.y = l
a.x = d
b.v = h
b.w = n
b.s = m
c.w = m
c.q = n
n.w = h
n.q = d
m.y = l
m.x = d
h.y = b
h.x = d
assert d.q.w.y.w.w.y.w.q.txt == "d"