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

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

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

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

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

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

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

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

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