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

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

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

k = A("k")
d = B("d")
g = C("g")
j = C("j")
c = B("c")
h = B("h")
n = C("n")
l = B("l")
i = A("i")

k.p = i
k.v = i
d.o = i
d.s = l
d.x = j
g.o = h
g.v = j
j.o = c
j.v = g
c.o = k
c.s = d
c.x = g
h.o = i
h.s = l
h.x = g
n.o = d
n.v = g
l.o = k
l.s = c
l.x = g
i.p = k
i.v = k
assert j.o.x.v.o.x.v.o.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: A = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
g = C("g")
j = C("j")
c = B("c")
h = B("h")
n = C("n")
l = B("l")
i = A("i")

k.p = i
k.v = i
d.o = i
d.s = l
d.x = j
g.o = h
g.v = j
j.o = c
j.v = g
c.o = k
c.s = d
c.x = g
h.o = i
h.s = l
h.x = g
n.o = d
n.v = g
l.o = k
l.s = c
l.x = g
i.p = k
i.v = k
assert j.o.x.v.o.x.v.o.o.p.txt == "i"