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

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

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

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

e = A("e")
c = B("c")
n = C("n")
k = D("k")
m = A("m")
h = C("h")
l = D("l")
b = D("b")
g = D("g")

e.v = h
e.t = l
e.r = c
c.p = n
c.x = n
c.q = l
n.z = m
n.q = h
n.x = c
n.v = c
k.w = c
k.v = e
m.v = n
m.t = k
m.r = c
h.z = m
h.q = n
h.x = c
h.v = c
l.w = c
l.v = m
b.w = c
b.v = e
g.w = c
g.v = e
assert h.q.z.t.w.x.z.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: D = None
        self.r: B = None
        self.txt = txt

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

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

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

e = A("e")
c = B("c")
n = C("n")
k = D("k")
m = A("m")
h = C("h")
l = D("l")
b = D("b")
g = D("g")

e.v = h
e.t = l
e.r = c
c.p = n
c.x = n
c.q = l
n.z = m
n.q = h
n.x = c
n.v = c
k.w = c
k.v = e
m.v = n
m.t = k
m.r = c
h.z = m
h.q = n
h.x = c
h.v = c
l.w = c
l.v = m
b.w = c
b.v = e
g.w = c
g.v = e
assert h.q.z.t.w.x.z.v.z.v.txt == "n"