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

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

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

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

b = A("b")
j = B("j")
i = C("i")
a = D("a")
g = A("g")
l = A("l")
d = A("d")
n = C("n")
e = A("e")
m = D("m")

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

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

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

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

b = A("b")
j = B("j")
i = C("i")
a = D("a")
g = A("g")
l = A("l")
d = A("d")
n = C("n")
e = A("e")
m = D("m")

b.r = a
b.u = a
j.u = i
i.v = n
i.o = e
i.p = l
a.u = b
a.p = j
a.x = n
a.v = n
g.r = m
g.u = a
l.r = a
l.u = m
d.r = m
d.u = m
n.v = i
n.o = d
n.p = g
e.r = a
e.u = m
m.u = e
m.p = j
m.x = i
m.v = n
assert a.p.u.o.r.u.r.v.v.p.u.txt == "m"