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

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

m = A("m")
j = B("j")
d = B("d")
i = B("i")
h = A("h")
k = B("k")
f = A("f")
l = B("l")
b = A("b")
g = A("g")

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

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

m = A("m")
j = B("j")
d = B("d")
i = B("i")
h = A("h")
k = B("k")
f = A("f")
l = B("l")
b = A("b")
g = A("g")

m.v = f
m.p = d
j.r = l
j.u = d
d.r = j
d.u = i
i.r = d
i.u = d
h.v = g
h.p = j
k.r = l
k.u = l
f.v = m
f.p = k
l.r = k
l.u = i
b.v = g
b.p = d
g.v = b
g.p = k
assert m.v.p.r.r.r.u.u.txt == "d"