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

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

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

a = A("a")
f = B("f")
i = C("i")
n = B("n")
m = B("m")
b = C("b")
d = A("d")
c = A("c")
l = A("l")
e = A("e")

a.r = b
a.w = n
a.o = f
f.q = i
i.w = e
i.q = b
i.p = f
n.q = i
m.q = i
b.w = d
b.q = i
b.p = m
d.r = b
d.w = f
d.o = m
c.r = b
c.w = n
c.o = f
l.r = i
l.w = n
l.o = m
e.r = b
e.w = f
e.o = n
assert d.r.q.w.o.q.w.r.q.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.w: B = None
        self.o: B = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
i = C("i")
n = B("n")
m = B("m")
b = C("b")
d = A("d")
c = A("c")
l = A("l")
e = A("e")

a.r = b
a.w = n
a.o = f
f.q = i
i.w = e
i.q = b
i.p = f
n.q = i
m.q = i
b.w = d
b.q = i
b.p = m
d.r = b
d.w = f
d.o = m
c.r = b
c.w = n
c.o = f
l.r = i
l.w = n
l.o = m
e.r = b
e.w = f
e.o = n
assert d.r.q.w.o.q.w.r.q.w.o.txt == "n"