class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.p: B = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
f = C("f")
l = B("l")
j = A("j")
d = A("d")
a = C("a")
k = B("k")

m.o = j
m.s = d
m.p = l
n.o = f
n.q = a
f.u = m
f.r = m
l.o = a
l.q = a
j.o = d
j.s = d
j.p = l
d.o = j
d.s = m
d.p = n
a.u = j
a.r = j
k.o = a
k.q = f
assert d.o.o.s.o.p.q.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.p: B = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
f = C("f")
l = B("l")
j = A("j")
d = A("d")
a = C("a")
k = B("k")

m.o = j
m.s = d
m.p = l
n.o = f
n.q = a
f.u = m
f.r = m
l.o = a
l.q = a
j.o = d
j.s = d
j.p = l
d.o = j
d.s = m
d.p = n
a.u = j
a.r = j
k.o = a
k.q = f
assert d.o.o.s.o.p.q.r.o.txt == "d"