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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
d = C("d")
e = D("e")
m = E("m")
k = F("k")
b = G("b")
c = D("c")
a = D("a")
f = F("f")

n.v = d
n.r = c
l.p = e
l.y = c
d.s = e
d.v = b
d.t = n
d.w = n
e.q = m
e.w = d
e.t = n
m.r = f
k.w = d
b.v = n
c.q = m
c.w = d
c.t = n
a.q = m
a.w = d
a.t = n
f.w = d
assert k.w.s.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
d = C("d")
e = D("e")
m = E("m")
k = F("k")
b = G("b")
c = D("c")
a = D("a")
f = F("f")

n.v = d
n.r = c
l.p = e
l.y = c
d.s = e
d.v = b
d.t = n
d.w = n
e.q = m
e.w = d
e.t = n
m.r = f
k.w = d
b.v = n
c.q = m
c.w = d
c.t = n
a.q = m
a.w = d
a.t = n
f.w = d
assert k.w.s.t.r.txt == "c"