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

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

j = A("j")
h = B("h")
c = A("c")
n = A("n")
k = B("k")
d = B("d")
e = A("e")
g = B("g")
a = A("a")
f = A("f")

j.r = g
h.v = d
h.p = d
c.r = d
n.r = d
k.v = d
k.p = g
d.v = k
d.p = g
e.r = d
g.v = h
g.p = h
a.r = g
f.r = g
assert j.r.p.v.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

j = A("j")
h = B("h")
c = A("c")
n = A("n")
k = B("k")
d = B("d")
e = A("e")
g = B("g")
a = A("a")
f = A("f")

j.r = g
h.v = d
h.p = d
c.r = d
n.r = d
k.v = d
k.p = g
d.v = k
d.p = g
e.r = d
g.v = h
g.p = h
a.r = g
f.r = g
assert j.r.p.v.v.p.txt == "g"