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

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

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

m = A("m")
g = B("g")
n = C("n")
k = B("k")
c = B("c")
b = C("b")
a = A("a")
i = B("i")
l = A("l")

m.p = b
g.q = a
g.y = b
n.u = g
n.w = b
k.q = m
k.y = b
c.q = l
c.y = b
b.u = c
b.w = n
a.p = n
i.q = a
i.y = n
l.p = n
assert m.p.w.w.u.q.p.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
n = C("n")
k = B("k")
c = B("c")
b = C("b")
a = A("a")
i = B("i")
l = A("l")

m.p = b
g.q = a
g.y = b
n.u = g
n.w = b
k.q = m
k.y = b
c.q = l
c.y = b
b.u = c
b.w = n
a.p = n
i.q = a
i.y = n
l.p = n
assert m.p.w.w.u.q.p.u.y.txt == "b"