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

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

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

c = A("c")
b = B("b")
m = C("m")
k = C("k")
f = A("f")
g = A("g")
j = B("j")
h = A("h")
i = A("i")
a = C("a")

c.r = a
b.p = k
b.v = f
b.u = j
m.r = i
m.s = k
k.r = g
k.s = a
f.r = a
g.r = m
j.p = k
j.v = g
j.u = b
h.r = k
i.r = m
a.r = i
a.s = m
assert a.s.s.s.r.r.s.s.s.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
m = C("m")
k = C("k")
f = A("f")
g = A("g")
j = B("j")
h = A("h")
i = A("i")
a = C("a")

c.r = a
b.p = k
b.v = f
b.u = j
m.r = i
m.s = k
k.r = g
k.s = a
f.r = a
g.r = m
j.p = k
j.v = g
j.u = b
h.r = k
i.r = m
a.r = i
a.s = m
assert a.s.s.s.r.r.s.s.s.s.r.txt == "g"