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

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

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

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

k = A("k")
n = B("n")
b = C("b")
a = D("a")
g = A("g")
m = A("m")
l = D("l")
h = C("h")
d = B("d")
i = D("i")

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

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

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

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

k = A("k")
n = B("n")
b = C("b")
a = D("a")
g = A("g")
m = A("m")
l = D("l")
h = C("h")
d = B("d")
i = D("i")

k.v = d
n.q = i
n.t = g
b.q = k
b.v = d
b.y = m
b.s = h
a.w = b
a.v = b
g.v = d
m.v = d
l.w = h
l.v = h
h.q = k
h.v = d
h.y = g
h.s = b
d.q = l
d.t = g
i.w = b
i.v = h
assert m.v.q.w.s.y.v.q.w.txt == "h"