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

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

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

k = A("k")
l = B("l")
g = C("g")
n = B("n")
i = B("i")
d = C("d")
a = A("a")
b = C("b")
f = B("f")

k.r = b
k.p = i
l.o = i
g.u = a
g.s = f
g.x = b
n.o = i
i.o = n
d.u = k
d.s = f
d.x = g
a.r = g
a.p = n
b.u = a
b.s = n
b.x = g
f.o = l
assert k.r.u.r.x.x.s.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.p: B = None
        self.txt = txt

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

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

k = A("k")
l = B("l")
g = C("g")
n = B("n")
i = B("i")
d = C("d")
a = A("a")
b = C("b")
f = B("f")

k.r = b
k.p = i
l.o = i
g.u = a
g.s = f
g.x = b
n.o = i
i.o = n
d.u = k
d.s = f
d.x = g
a.r = g
a.p = n
b.u = a
b.s = n
b.x = g
f.o = l
assert k.r.u.r.x.x.s.o.o.o.txt == "n"