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

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

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

n = A("n")
b = B("b")
f = C("f")
g = C("g")
m = A("m")
j = A("j")
k = C("k")
h = C("h")
d = C("d")
e = C("e")

n.s = e
n.u = m
n.q = b
b.z = e
b.q = h
f.u = d
f.p = b
g.u = d
g.p = b
m.s = g
m.u = j
m.q = b
j.s = g
j.u = n
j.q = b
k.u = g
k.p = b
h.u = g
h.p = b
d.u = k
d.p = b
e.u = g
e.p = b
assert k.p.z.u.u.u.p.z.u.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: A = None
        self.q: B = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
f = C("f")
g = C("g")
m = A("m")
j = A("j")
k = C("k")
h = C("h")
d = C("d")
e = C("e")

n.s = e
n.u = m
n.q = b
b.z = e
b.q = h
f.u = d
f.p = b
g.u = d
g.p = b
m.s = g
m.u = j
m.q = b
j.s = g
j.u = n
j.q = b
k.u = g
k.p = b
h.u = g
h.p = b
d.u = k
d.p = b
e.u = g
e.p = b
assert k.p.z.u.u.u.p.z.u.u.p.txt == "b"