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

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

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

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

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

b.s = g
n.v = k
n.u = b
n.q = d
m.q = g
m.z = b
m.r = b
a.v = g
h.q = g
h.z = b
h.r = b
d.v = h
l.q = m
l.z = b
l.r = b
g.q = h
g.z = b
g.r = b
k.v = n
k.u = b
k.q = a
assert b.s.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

b.s = g
n.v = k
n.u = b
n.q = d
m.q = g
m.z = b
m.r = b
a.v = g
h.q = g
h.z = b
h.r = b
d.v = h
l.q = m
l.z = b
l.r = b
g.q = h
g.z = b
g.r = b
k.v = n
k.u = b
k.q = a
assert b.s.q.q.q.q.q.txt == "h"