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

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

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

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

n = A("n")
i = B("i")
c = C("c")
d = D("d")
m = B("m")
k = B("k")
f = D("f")
l = C("l")
a = A("a")

n.r = d
n.w = m
i.w = l
i.r = m
i.q = n
i.v = f
c.v = m
d.w = f
m.w = l
m.r = k
m.q = a
m.v = d
k.w = c
k.r = i
k.q = a
k.v = d
f.w = d
l.v = k
a.r = f
a.w = m
assert a.r.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: B = None
        self.txt = txt

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

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

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

n = A("n")
i = B("i")
c = C("c")
d = D("d")
m = B("m")
k = B("k")
f = D("f")
l = C("l")
a = A("a")

n.r = d
n.w = m
i.w = l
i.r = m
i.q = n
i.v = f
c.v = m
d.w = f
m.w = l
m.r = k
m.q = a
m.v = d
k.w = c
k.r = i
k.q = a
k.v = d
f.w = d
l.v = k
a.r = f
a.w = m
assert a.r.w.w.w.w.w.w.w.txt == "d"