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

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

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

d = A("d")
b = B("b")
g = C("g")
e = A("e")
k = A("k")
c = B("c")
a = B("a")
l = A("l")
n = A("n")

d.p = a
d.r = b
b.o = g
g.v = d
g.t = k
e.p = c
e.r = c
k.p = b
k.r = a
c.o = g
a.o = g
l.p = c
l.r = b
n.p = b
n.r = b
assert e.p.o.v.r.o.v.p.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: B = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
g = C("g")
e = A("e")
k = A("k")
c = B("c")
a = B("a")
l = A("l")
n = A("n")

d.p = a
d.r = b
b.o = g
g.v = d
g.t = k
e.p = c
e.r = c
k.p = b
k.r = a
c.o = g
a.o = g
l.p = c
l.r = b
n.p = b
n.r = b
assert e.p.o.v.r.o.v.p.o.v.txt == "d"