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

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

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

d = A("d")
l = B("l")
b = C("b")
j = C("j")
k = A("k")
m = A("m")
a = C("a")
g = B("g")
i = B("i")

d.v = k
d.r = k
d.p = k
l.o = g
l.r = b
b.r = g
b.v = i
j.r = g
j.v = g
k.v = d
k.p = d
k.r = m
m.v = k
m.r = d
m.p = d
a.r = l
a.v = l
g.o = l
g.r = b
i.o = g
i.r = b
assert g.o.o.r.r.r.v.r.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: A = None
        self.p: A = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
b = C("b")
j = C("j")
k = A("k")
m = A("m")
a = C("a")
g = B("g")
i = B("i")

d.v = k
d.r = k
d.p = k
l.o = g
l.r = b
b.r = g
b.v = i
j.r = g
j.v = g
k.v = d
k.p = d
k.r = m
m.v = k
m.r = d
m.p = d
a.r = l
a.v = l
g.o = l
g.r = b
i.o = g
i.r = b
assert g.o.o.r.r.r.v.r.r.o.txt == "l"